Submit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result.
(coro, loop)
| 1005 | |
| 1006 | |
| 1007 | def run_coroutine_threadsafe(coro, loop): |
| 1008 | """Submit a coroutine object to a given event loop. |
| 1009 | |
| 1010 | Return a concurrent.futures.Future to access the result. |
| 1011 | """ |
| 1012 | if not coroutines.iscoroutine(coro): |
| 1013 | raise TypeError('A coroutine object is required') |
| 1014 | future = concurrent.futures.Future() |
| 1015 | |
| 1016 | def callback(): |
| 1017 | try: |
| 1018 | futures._chain_future(ensure_future(coro, loop=loop), future) |
| 1019 | except (SystemExit, KeyboardInterrupt): |
| 1020 | raise |
| 1021 | except BaseException as exc: |
| 1022 | if future.set_running_or_notify_cancel(): |
| 1023 | future.set_exception(exc) |
| 1024 | raise |
| 1025 | |
| 1026 | loop.call_soon_threadsafe(callback) |
| 1027 | return future |
| 1028 | |
| 1029 | |
| 1030 | def create_eager_task_factory(custom_task_constructor): |
nothing calls this directly
no test coverage detected
searching dependent graphs…