remove_event_loop: Allow ignoring specific errors

Replaces a bare except with Exception, and updates the
test case to specify only a single exception that is
allowed to occur.

Related to https://github.com/capnproto/pycapnp/issues/254
This commit is contained in:
John Vandenberg
2021-06-01 16:27:34 +08:00
parent bd91c52d57
commit 4797654323
2 changed files with 28 additions and 7 deletions

View File

@@ -9,6 +9,9 @@ import threading
import pytest
import capnp
from capnp.lib.capnp import KjException
import test_capability_capnp
@@ -35,11 +38,19 @@ def test_making_threaded_event_loop():
'''
Threaded event loop test
'''
capnp.remove_event_loop(True)
capnp.create_event_loop(True)
# The following raises a KjException, and if not caught causes an SIGABRT:
# kj/async.c++:973: failed: expected head == nullptr; EventLoop destroyed with events still in the queue.
# Memory leak?; head->trace() = kj::_::ForkHub<kj::_::Void>
# kj::_::AdapterPromiseNode<kj::_::Void, kj::_::PromiseAndFulfillerAdapter<void> >
# stack: ...
# python(..) malloc: *** error for object 0x...: pointer being freed was not allocated
# python(..) malloc: *** set a breakpoint in malloc_error_break to debug
# Fatal Python error: Aborted
capnp.remove_event_loop(KjException)
capnp.create_event_loop(KjException)
capnp.remove_event_loop()
capnp.create_event_loop(True)
capnp.create_event_loop(KjException)
class Server(test_capability_capnp.TestInterface.Server):