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 asvetlov, mbussonn, yselivanov
Date 2019-12-02.18:39:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575311987.47.0.389219942485.issue38955@roundup.psfhosted.org>
In-reply-to
Content
Hi, Not sure if this a bug, or an intended feature. 
I got surprise by the following behavior. 


    from asyncio import run, sleep, get_event_loop

    print(get_event_loop()) # return the current eventloop
    run(sleep(0))
    print(get_event_loop()) # raise a RuntimeError


I would expect `get_event_loop` to get back to it's initial default value. 

This comes from the fact that `run()` call `set_event_loop()` to `None`. with
both sets `_set_called` to `True`, but `get_event_loop` seem to assume if
_set_called is True, then loop cannot be none. 

I'm tempted to think that if `set_loop()` is called with `None`, it should reset the `_set_called` to False. Or Am I supposed to call `set_event_loop(new_event_loop())` myself ? 

I'm likely missing  something so any insight would be appreciated; if you
believe this is an actual issue I'm happy to send a PR.
History
Date User Action Args
2019-12-02 18:39:47mbussonnsetrecipients: + mbussonn, asvetlov, yselivanov
2019-12-02 18:39:47mbussonnsetmessageid: <1575311987.47.0.389219942485.issue38955@roundup.psfhosted.org>
2019-12-02 18:39:47mbussonnlinkissue38955 messages
2019-12-02 18:39:47mbussonncreate