mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
Docs and one small improvement for issue #25304, by Vincent Michel.
This commit is contained in:
parent
b9bf913ab3
commit
601953b679
4 changed files with 75 additions and 4 deletions
|
@ -704,7 +704,12 @@ def run_coroutine_threadsafe(coro, loop):
|
|||
future = concurrent.futures.Future()
|
||||
|
||||
def callback():
|
||||
futures._chain_future(ensure_future(coro, loop=loop), future)
|
||||
try:
|
||||
futures._chain_future(ensure_future(coro, loop=loop), future)
|
||||
except Exception as exc:
|
||||
if future.set_running_or_notify_cancel():
|
||||
future.set_exception(exc)
|
||||
raise
|
||||
|
||||
loop.call_soon_threadsafe(callback)
|
||||
return future
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue