Guest User

Untitled

a guest
Jun 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import asyncio
  2.  
  3. futures = []
  4. loop = asyncio.get_event_loop()
  5. for coroutine in coroutines:
  6. futures.append(asyncio.run_coroutine_threadsafe(coroutine, event_loop))
  7. for future in futures:
  8. future.result()
  9.  
  10. in main
  11. future.result()
  12. File "/usr/lib/python3.5/asyncio/futures.py", line 268, in result
  13. raise InvalidStateError('Result is not ready.')
  14.  
  15. futures._chain_future(ensure_future(coro, loop=loop), future)
  16.  
  17. def result(self):
  18. """Return the result this future represents.
  19. If the future has been cancelled, raises CancelledError. If the
  20. future's result isn't yet available, raises InvalidStateError. If
  21. the future is done and has an exception set, this exception is raised.
  22. """
  23. if self._state == _CANCELLED:
  24. raise CancelledError
  25. if self._state != _FINISHED:
  26. raise InvalidStateError('Result is not ready.')
  27. self._log_traceback = False
  28. if self._tb_logger is not None:
  29. self._tb_logger.clear()
  30. self._tb_logger = None
  31. if self._exception is not None:
  32. raise self._exception
  33. return self._result
Add Comment
Please, Sign In to add comment