[issue34344] Fix the docstring for AbstractEventLoopPolicy.get_event_loop
Karthikeyan Singaravelan
report at bugs.python.org
Thu Sep 12 07:39:32 EDT 2019
Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:
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
----------
versions: +Python 3.9 -Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34344>
_______________________________________
More information about the Python-bugs-list
mailing list