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 yselivanov
Recipients chris.jerdonek, giampaolo.rodola, mbussonn, ncoghlan, njs, yselivanov
Date 2018-01-24.05:06:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516770390.68.0.467229070634.issue30491@psf.upfronthosting.co.za>
In-reply-to
Content
Guido,

This is another feature for native coroutines that Nathaniel proposes for 3.7.

Here's a summary (this issue has too many messages):

1. It adds a new mechanism to detect un-awaited coroutines (i.e. when a user forgets to use await).

2. To enable the mechanism, which is disabled by default, a "sys. set_unawaited_coroutine_tracking_enabled()" function needs to be called by a framework.

3. "sys.get_unawaited_coroutines()" returns a list of not-yet-awaited native-coroutine objects that were created since the previous call to "get_unawaited_coroutines()".

4. In Trio, the APIs are designed to accept *coroutine functions*.  So in Trio, a user either writes "await coro()" or passes "coro" to a Trio API.  Nathaniel wants Trio to check periodically if there are any un-awaited coroutines and raise an error, which should improve Trio usability.

5. Another potential user of this new functionality is pytest-asyncio. It can use the API to warn the user that a test created some coroutines that were never awaited. 

6. asyncio/tornado/curio/twisted will not be able to use this API.

7. Effectively, the previously merged origin-tracking API (the one with which we replaced set_coroutine_wrapper) achieves the same goal.  The only downside is that the warning won't be raised until GC.  On other interpreters like PyPy it can take a while before a coroutine gets GCed.

8. The patch adds two pointers to native coroutines objects to maintain a doubly-linked list of them.

9. The performance impact is visible in micro-benchmarks, but is unlikely be visible in real applications.  Still, it's about 3-4% slowdown for both generators and coroutines.

10. The PR itself is in a good shape, although I'll still make a review pass if you approve this feature to go in 3.7.

What do you think?
History
Date User Action Args
2018-01-24 05:06:30yselivanovsetrecipients: + yselivanov, ncoghlan, giampaolo.rodola, njs, chris.jerdonek, mbussonn
2018-01-24 05:06:30yselivanovsetmessageid: <1516770390.68.0.467229070634.issue30491@psf.upfronthosting.co.za>
2018-01-24 05:06:30yselivanovlinkissue30491 messages
2018-01-24 05:06:30yselivanovcreate