This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio is not inspecting keyword arguments of functools.partial
Type: Stage: resolved
Components: asyncio Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, iceboy, python-dev, vstinner, yselivanov
Priority: normal Keywords:

Created on 2016-03-28 09:57 by iceboy, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (6)
msg262566 - (view) Author: iceboy (iceboy) * Date: 2016-03-28 09:57
import asyncio
import functools

def foo(x): raise Exception()

loop = asyncio.get_event_loop()
loop.call_soon(functools.partial(foo, x=1))
loop.run_forever()

Current error message:
    Exception in callback foo()() at ...:4

Expected error message:
    Exception in callback foo(x=1)() at ...:4
msg262588 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-03-29 01:35
Oh, wow. I didn't even know we special-case partial() there. In general we tend to focus more on positional arguments (since asyncio intentionally doesn't take keyword args for callbacks) but I see no reason why we couldn't add this here. Maybe you're interested in writing a patch yourself? You could do it as a PR for the "upstream" git repo https://github.com/python/asyncio
msg262608 - (view) Author: iceboy (iceboy) * Date: 2016-03-29 12:40
Created a PR https://github.com/python/asyncio/pull/328. Please review. Thanks.
msg262631 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-29 21:54
> Oh, wow. I didn't even know we special-case partial() there.

I wrote the code doing that. I did it to get more readable and shorter logs since asyncio produces a lot of logs.

Example:

    Exception in callback print("Hello", "World!")() at ...:4

without special case:

    Exception in functools.partial(<built-in function print>, 'Hello', 'World!') at ...:4
msg276610 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-15 20:02
New changeset 4ab64ea31d75 by Yury Selivanov in branch '3.5':
Issue #26654: Inspect functools.partial in asyncio.Handle.__repr__.
https://hg.python.org/cpython/rev/4ab64ea31d75

New changeset 03257f04ee9f by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #26654)
https://hg.python.org/cpython/rev/03257f04ee9f

New changeset 1dbe3addba28 by Yury Selivanov in branch 'default':
Merge 3.6 (issue #26654)
https://hg.python.org/cpython/rev/1dbe3addba28
msg276611 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-09-15 20:02
Merged! Thank you!
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70841
2017-03-31 16:36:35dstufftsetpull_requests: + pull_request1083
2016-09-15 20:02:53yselivanovsetstatus: open -> closed
resolution: fixed
messages: + msg276611

stage: resolved
2016-09-15 20:02:23python-devsetnosy: + python-dev
messages: + msg276610
2016-03-29 21:54:39vstinnersetmessages: + msg262631
2016-03-29 12:40:15iceboysetmessages: + msg262608
2016-03-29 01:35:39gvanrossumsetmessages: + msg262588
2016-03-28 09:57:30iceboycreate