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 xtreak
Recipients asvetlov, docs@python, drtyrsa, xtreak, yselivanov
Date 2019-09-12.11:39:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568288372.14.0.15084571934.issue34344@roundup.psfhosted.org>
In-reply-to
Content
Thanks for the report. This looks like a valid change to me as I can see from the docstring it says it can be None but in the source code there is an explicit check that if self._local._loop which is returned is None then raise a RuntimeError. I would propose removing the docstring in the example.


# Docstring says can be None

./python.exe -m pydoc asyncio.events.BaseDefaultEventLoopPolicy.get_event_loop | cat
Help on function get_event_loop in asyncio.events.BaseDefaultEventLoopPolicy:

asyncio.events.BaseDefaultEventLoopPolicy.get_event_loop = get_event_loop(self)
    Get the event loop.

    This may be None or an instance of EventLoop.


# RuntimeError is raised for None

./python.exe -m inspect asyncio.events:BaseDefaultEventLoopPolicy.get_event_loop
    def get_event_loop(self):
        """Get the event loop.

        This may be None or an instance of EventLoop.
        """
        if (self._local._loop is None and
                not self._local._set_called and
                isinstance(threading.current_thread(), threading._MainThread)):
            self.set_event_loop(self.new_event_loop())

        if self._local._loop is None:
            raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)

        return self._local._loop
History
Date User Action Args
2019-09-12 11:39:32xtreaksetrecipients: + xtreak, asvetlov, docs@python, yselivanov, drtyrsa
2019-09-12 11:39:32xtreaksetmessageid: <1568288372.14.0.15084571934.issue34344@roundup.psfhosted.org>
2019-09-12 11:39:32xtreaklinkissue34344 messages
2019-09-12 11:39:32xtreakcreate