New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio: remove _TracebackLogger #64166
Comments
Thanks to the PEP-442 (Safe object finalization), _TracebackLogger helper of asyncio.Futures becomes useless. Attached patch removes it. -- If you agree to diverge code with Tulip project, the Python 3.3 code of WriteTransport.writelines can also be removed: if not PY34:
# In Python 3.3, bytes.join() doesn't handle memoryview.
list_of_data = (
bytes(data) if isinstance(data, memoryview) else data
for data in list_of_data) |
I'm sorry, I really don't want the asyncio code for 3.3 and 3.4 to diverge just yet. It would make keeping the two versions in sync just so much harder. I'm happy with something that checks for the version and either adds the __del__ method (for 3.4) or uses the _TracebackLogger (for 3.3). |
Ok. Here is a patch. The class is still defined on Python 3.4. You may move the definition of the class in a "if not PY34:" class. I did not the change to have a shorter patch. |
Updated patch to address Guido's comments. |
So the new patch is fine, but I still think it's confusing that the _tb_logger variable has a different type depending on the Python version. If you really don't want to fix this, just go ahead and check in, it's not a blocker. |
"So the new patch is fine, but I still think it's confusing that the _tb_logger variable has a different type depending on the Python version." To be honest, I'm also concerned by this strange variable :-) Here is a new fix which reuses the name used in the first patch (_traceback). |
asyncio_log_traceback-5.patch: new try :-) |
Looks good. I can fix that long line myself. :-) |
New changeset 5e9728ebb1d3 by Victor Stinner in branch 'default': |
I think this patch is bad and should be reverted. It always calls traceback.format_exception() which is an expensive operation, while the _TracebackLogger takes care to call it only when necessary. |
Eew. You're right. Sorry I didn't see this. |
Oh, I didn't notice that, and I agree that the new code is inefficient. Since the Future object does not release the reference to the exception after result() or exception() has been called, there is no need to preformat the exception. It can be done in the destructor. Attached asyncio_defer_format_tb.patch implements that. Future.set_exception() creates a reference cycle. I created the issue bpo-20032 to discuss that. |
Victor, can you commit the fix (with my suggested improvement)? |
New changeset 06ed1691efdc by Victor Stinner in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: