Matthias Bussonnier <bussonniermatth...@gmail.com> added the comment:

Your last description is about exactly what 
https://github.com/python-trio/trio/pull/176 is about (which I need to resurect)

There are some issue with weakref some that I don't remember, but one of them 
is (IIRC): what if a non-awaited coro get collected before being awaited and 
check by trio ? 

   send_ping() # don't care about result, forgot await
   # get collected
   await something_that_will_trigger_check_coros_weakreaf() # oh no !

   
So if its weak-refd then you can't be sure you are actually preventing 
non-awaited coros.

By default in trio we also would like to enforce immediate coro awaiting, but 
we of course would provide a convenience function to wrap coroutines you really 
do not want to await now. (Explicit is better than implicit) So you would write:

    c = coro()
    really_not_awaiting_now_leave_me_alone(c)
    await ... #
    nursery.start_soon(c)

What above PR does is check each time you enter the trio scheduler whether 
there is unawaited Coros (not marked as really_no_not_awaiting_now), and if so, 
next time you restart this task (or enter an cancellation point.. but details) 
raise a NonAwaitedCoroutineError. It does not raise _exactly_ where it was not 
awaited but narrow down where the non-awaited coro is (between two schedule 
point). And _if_ you enable tracemalloc the error message give you where the 
stack trace that created this coro.

----------

_______________________________________
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