From cfc11e4a8ac90b8d0d980384ee37d61abd51f95c Mon Sep 17 00:00:00 2001 From: Jason Paryani Date: Mon, 2 Dec 2013 17:54:53 -0800 Subject: [PATCH] Fix bug in removing an EventLoop --- capnp/capnp.pyx | 7 ++++--- examples/example_client.py | 3 +-- test/test_rpc.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capnp/capnp.pyx b/capnp/capnp.pyx index 9084bcf..f22f1ca 100644 --- a/capnp/capnp.pyx +++ b/capnp/capnp.pyx @@ -1173,10 +1173,11 @@ cdef class _EventLoop: self.thisptr = new UnixEventLoop() def __dealloc__(self): - del self.thisptr + self.remove() - def delete(self): + cpdef remove(self) except +reraise_kj_exception: del self.thisptr + self.thisptr = NULL # cpdef evalLater(self, func): # Py_INCREF(func) @@ -1215,7 +1216,7 @@ DEFAULT_EVENT_LOOP = _EventLoop() def remove_event_loop(): global DEFAULT_EVENT_LOOP - DEFAULT_EVENT_LOOP.delete() + DEFAULT_EVENT_LOOP.remove() DEFAULT_EVENT_LOOP = None cdef class _CallContext: diff --git a/examples/example_client.py b/examples/example_client.py index d5ce706..19b911f 100644 --- a/examples/example_client.py +++ b/examples/example_client.py @@ -12,8 +12,7 @@ def example_client(): cap = client.restore(test_capnp.TestSturdyRefObjectId.new_message(tag='testInterface')) cap = cap.cast_as(test_capnp.TestInterface) - remote = cap.foo(i=5) - response = remote.wait() + response = cap.foo(i=5).wait() assert response.x == '125' c.close() diff --git a/test/test_rpc.py b/test/test_rpc.py index abfb3cc..03eace2 100644 --- a/test/test_rpc.py +++ b/test/test_rpc.py @@ -35,8 +35,8 @@ def test_simple_rpc(capability): assert response.x == '125' -# def test_custom_event_loop(capability): -# capnp.remove_event_loop() -# capnp.DEFAULT_EVENT_LOOP = capnp._EventLoop() +def test_custom_event_loop(capability): + capnp.remove_event_loop() + capnp.DEFAULT_EVENT_LOOP = capnp._EventLoop() -# test_simple_rpc(capability) \ No newline at end of file + test_simple_rpc(capability) \ No newline at end of file