Allow cancellation of all capability contexts
This commit is contained in:
committed by
Jacob Alexander
parent
49bda5ccae
commit
0ec4d0b778
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import asyncio
|
||||
|
||||
import capnp
|
||||
import test_capability_capnp as capability
|
||||
@@ -389,3 +390,22 @@ async def test_generic():
|
||||
obj = capnp._MallocMessageBuilder().get_root_as_any()
|
||||
obj.set_as_text("anypointer_")
|
||||
assert (await client.foo(obj)).b == "anypointer_test"
|
||||
|
||||
|
||||
class CancelServer(capability.TestInterface.Server):
|
||||
def __init__(self, val=1):
|
||||
self.val = val
|
||||
|
||||
async def foo(self, i, j, **kwargs):
|
||||
with pytest.raises(asyncio.CancelledError):
|
||||
await asyncio.sleep(10)
|
||||
|
||||
|
||||
async def test_cancel2():
|
||||
client = capability.TestInterface._new_client(CancelServer())
|
||||
|
||||
task = asyncio.ensure_future(client.foo(1, True))
|
||||
await asyncio.sleep(0) # Make sure that the task runs
|
||||
task.cancel()
|
||||
with pytest.raises(asyncio.CancelledError):
|
||||
await task
|
||||
|
||||
Reference in New Issue
Block a user