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 mbussonn
Recipients chris.jerdonek, giampaolo.rodola, mbussonn, ncoghlan, njs, yselivanov
Date 2017-12-13.17:19:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513185583.73.0.213398074469.issue30491@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-13 17:19:43mbussonnsetrecipients: + mbussonn, ncoghlan, giampaolo.rodola, njs, chris.jerdonek, yselivanov
2017-12-13 17:19:43mbussonnsetmessageid: <1513185583.73.0.213398074469.issue30491@psf.upfronthosting.co.za>
2017-12-13 17:19:43mbussonnlinkissue30491 messages
2017-12-13 17:19:43mbussonncreate