Skip to content
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

Closed
vstinner opened this issue Dec 12, 2013 · 14 comments
Closed

asyncio: remove _TracebackLogger #64166

vstinner opened this issue Dec 12, 2013 · 14 comments
Assignees

Comments

@vstinner
Copy link
Member

BPO 19967
Nosy @gvanrossum, @pitrou, @vstinner
Files
  • asyncio_log_traceback.patch
  • asyncio_log_traceback-2.patch
  • asyncio_log_traceback-3.patch
  • asyncio_log_traceback-4.patch
  • asyncio_log_traceback-5.patch
  • asyncio_defer_format_tb.patch
  • 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:

    assignee = 'https://github.com/vstinner'
    closed_at = <Date 2013-12-20.23:21:31.996>
    created_at = <Date 2013-12-12.23:02:49.275>
    labels = []
    title = 'asyncio: remove _TracebackLogger'
    updated_at = <Date 2013-12-20.23:21:31.996>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2013-12-20.23:21:31.996>
    actor = 'vstinner'
    assignee = 'vstinner'
    closed = True
    closed_date = <Date 2013-12-20.23:21:31.996>
    closer = 'vstinner'
    components = []
    creation = <Date 2013-12-12.23:02:49.275>
    creator = 'vstinner'
    dependencies = []
    files = ['33106', '33107', '33214', '33220', '33221', '33229']
    hgrepos = []
    issue_num = 19967
    keywords = ['patch']
    message_count = 14.0
    messages = ['205988', '205990', '205992', '206625', '206627', '206640', '206644', '206648', '206652', '206656', '206657', '206673', '206714', '206716']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'pitrou', 'vstinner', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue19967'
    versions = ['Python 3.4']

    @vstinner
    Copy link
    Member Author

    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)

    @gvanrossum
    Copy link
    Member

    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).

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    Updated patch to address Guido's comments.

    @gvanrossum
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member Author

    "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).

    @vstinner
    Copy link
    Member Author

    asyncio_log_traceback-5.patch: new try :-)

    @gvanrossum
    Copy link
    Member

    Looks good. I can fix that long line myself. :-)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 19, 2013

    New changeset 5e9728ebb1d3 by Victor Stinner in branch 'default':
    Close bpo-19967: Thanks to the PEP-442, asyncio.Future can use a destructor in
    http://hg.python.org/cpython/rev/5e9728ebb1d3

    @python-dev python-dev mannequin closed this as completed Dec 19, 2013
    @pitrou
    Copy link
    Member

    pitrou commented Dec 20, 2013

    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.

    @gvanrossum
    Copy link
    Member

    Eew. You're right. Sorry I didn't see this.

    @vstinner
    Copy link
    Member Author

    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.

    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.

    @gvanrossum
    Copy link
    Member

    Victor, can you commit the fix (with my suggested improvement)?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 20, 2013

    New changeset 06ed1691efdc by Victor Stinner in branch 'default':
    Issue bpo-19967: Defer the formating of the traceback in asyncio.Future destructor
    http://hg.python.org/cpython/rev/06ed1691efdc

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants