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 hfingler
Recipients docs@python, hfingler
Date 2018-03-21.21:06:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521666406.67.0.467229070634.issue33117@psf.upfronthosting.co.za>
In-reply-to
Content
In the documentation of asyncio.run_coroutine_threadsafe(coro, loop), in Section 19.5.3.6 (https://docs.python.org/3/library/asyncio-task.html#asyncio.run_coroutine_threadsafe), the example code does the following:

    future = asyncio.run_coroutine_threadsafe(coro, loop)
    # Wait for the result with an optional timeout argument
    assert future.result(timeout) == 3

 The problem is that the result method of a future, according to the documentation doesn't take parameters. It's in Section 19.5.3.4 (https://docs.python.org/3.8/library/asyncio-task.html#asyncio.Future.done)

    result()
        Return the result this future represents.


 The same function is used in Section 18.5.9.3 (https://docs.python.org/3/library/asyncio-dev.html#concurrency-and-multithreading)


 This error is present in all Python 3.* docs.

 From the asyncio source code (https://github.com/python/cpython/blob/master/Lib/asyncio/futures.py), we have this in the Future class definition:

class Future:
    """This class is *almost* compatible with concurrent.futures.Future.
    Differences:
    - This class is not thread-safe.
    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    ....

So this example needs to be reworked, I'd do it if I knew more about asyncio. My ideas involve either using a add_done_callback with a flag or just busy waiting until future.done().
History
Date User Action Args
2018-03-21 21:06:46hfinglersetrecipients: + hfingler, docs@python
2018-03-21 21:06:46hfinglersetmessageid: <1521666406.67.0.467229070634.issue33117@psf.upfronthosting.co.za>
2018-03-21 21:06:46hfinglerlinkissue33117 messages
2018-03-21 21:06:46hfinglercreate