This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients asvetlov, docs@python, giampaolo.rodola, hfingler, xtreak, yselivanov
Date 2018-09-20.12:57:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I think `asyncio.run_coroutine_threadsafe(coro, loop)` returns a concurrent.futures.Future [1] which supports timeout and not asyncio.Future which doesn't support timeout. Please add in if I am missing anything. Since asyncio docs are being rewritten this would be a great time to contribute too if you would like to add more clarification.

Docs at [1] also say the below : 

asyncio.run_coroutine_threadsafe(coro, loop)

    Submit a coroutine to the given event loop. Thread-safe.

    Return a concurrent.futures.Future to wait for the result from another OS thread.

# This needs to be called from a different thread as docs said but I am using future.result(timeout) just to make sure there is no error with respect to function argument.

import asyncio

loop = asyncio.get_event_loop()
timeout = 4

# Create a coroutine
coro = asyncio.sleep(1, result=3)

# Submit the coroutine to a given loop
future = asyncio.run_coroutine_threadsafe(coro, loop)

# Wait for the result with an optional timeout argument
assert future.result(timeout) == 3

➜  cpython git:(master) ./python.exe
Traceback (most recent call last):
  File "../", line 13, in <module>
    assert future.result(timeout) == 3
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/concurrent/futures/", line 438, in result
    raise TimeoutError()


Date User Action Args
2018-09-20 12:57:47xtreaksetrecipients: + xtreak, giampaolo.rodola, asvetlov, docs@python, yselivanov, hfingler
2018-09-20 12:57:47xtreaksetmessageid: <>
2018-09-20 12:57:47xtreaklinkissue33117 messages
2018-09-20 12:57:47xtreakcreate