mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-38785: Prevent asyncio from crashing (GH-17144)
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785
This commit is contained in:
parent
61289d4366
commit
dad6be5ffe
4 changed files with 46 additions and 1 deletions
|
@ -115,7 +115,10 @@ class Future:
|
|||
|
||||
def get_loop(self):
|
||||
"""Return the event loop the Future is bound to."""
|
||||
return self._loop
|
||||
loop = self._loop
|
||||
if loop is None:
|
||||
raise RuntimeError("Future object is not initialized.")
|
||||
return loop
|
||||
|
||||
def cancel(self):
|
||||
"""Cancel the future and schedule callbacks.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue