Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- futures = []
- loop = asyncio.get_event_loop()
- for coroutine in coroutines:
- futures.append(asyncio.run_coroutine_threadsafe(coroutine, event_loop))
- for future in futures:
- future.result()
- in main
- future.result()
- File "/usr/lib/python3.5/asyncio/futures.py", line 268, in result
- raise InvalidStateError('Result is not ready.')
- futures._chain_future(ensure_future(coro, loop=loop), future)
- def result(self):
- """Return the result this future represents.
- If the future has been cancelled, raises CancelledError. If the
- future's result isn't yet available, raises InvalidStateError. If
- the future is done and has an exception set, this exception is raised.
- """
- if self._state == _CANCELLED:
- raise CancelledError
- if self._state != _FINISHED:
- raise InvalidStateError('Result is not ready.')
- self._log_traceback = False
- if self._tb_logger is not None:
- self._tb_logger.clear()
- self._tb_logger = None
- if self._exception is not None:
- raise self._exception
- return self._result
Add Comment
Please, Sign In to add comment