Yury Selivanov <yseliva...@gmail.com> added the comment:

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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30491>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to