mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Corner case for cancelled server methods that raise exceptions
When a server method is cancelled, but it nonetheless raises an exception (other than `CancelledError`), this exception cannot be reported to the caller (because it has cancelled that call). The only place where it can go is to the asyncio exception handler...
This commit is contained in:
parent
0ec4d0b778
commit
b6ea909e9a
1 changed files with 9 additions and 0 deletions
|
@ -76,6 +76,15 @@ cdef class _VoidPromiseFulfiller:
|
||||||
|
|
||||||
def void_task_done_callback(method_name, _VoidPromiseFulfiller fulfiller, task):
|
def void_task_done_callback(method_name, _VoidPromiseFulfiller fulfiller, task):
|
||||||
if fulfiller.fulfiller == NULL:
|
if fulfiller.fulfiller == NULL:
|
||||||
|
if not task.cancelled():
|
||||||
|
exc = task.exception()
|
||||||
|
if exc is not None:
|
||||||
|
context = {
|
||||||
|
'message': f"Cancelled server method {method_name} raised an exception",
|
||||||
|
'exception': exc,
|
||||||
|
'task': task,
|
||||||
|
}
|
||||||
|
asyncio.get_running_loop().call_exception_handler(context)
|
||||||
return
|
return
|
||||||
|
|
||||||
if task.cancelled():
|
if task.cancelled():
|
||||||
|
|
Loading…
Add table
Reference in a new issue