bpo-38785: Prevent asyncio from crashing #17144
Conversation
constructor of object derived from asyncio.Future
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
Note: I would prefer to rename "ENSURE_FUTURE_ALIVE" to "ENSURE_FUTURE_INITIALIZED", but that can be done in a separated PR and it's unrelated to the issue :-)
I tested manually this PR: it does fix https://bugs.python.org/issue38785
Without this PR, the example crash.
With this PR, I get a warning an no crash:
vstinner@apu$ ./python scratch_15.py
In tratata before
In tratata2 before
Exception in callback <TaskStepMethWrapper object at 0x7f3ccfb878c0>()
handle: <Handle <TaskStepMethWrapper object at 0x7f3ccfb878c0>()>
Traceback (most recent call last):
File "/home/vstinner/python/master/Lib/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Future object is not initialized.
In tratata after
|
Yes, RuntimeError was my intention. |
|
Sorry, I can't merge this PR. Reason: |
|
Thanks @asvetlov for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8. |
|
GH-17147 is a backport of this pull request to the 3.8 branch. |
|
GH-17148 is a backport of this pull request to the 3.7 branch. |
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785 (cherry picked from commit dad6be5) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785 (cherry picked from commit dad6be5) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785 (cherry picked from commit dad6be5) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785
if parent `__init__` is not called from a constructor of object derived from `asyncio.Future` https://bugs.python.org/issue38785
if parent
__init__is not called from a constructor of object derived fromasyncio.Futurehttps://bugs.python.org/issue38785
Automerge-Triggered-By: @asvetlov