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:
committed by
Jacob Alexander
parent
0ec4d0b778
commit
b6ea909e9a
@@ -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():
|
||||||
|
|||||||
Reference in New Issue
Block a user