[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-20 Thread Yury Selivanov


Yury Selivanov  added the comment:

> It does seem like a good solution.

Great. I'll close this issue then as the proposed solution is actually not as 
straightforward as it seems. Task names exist specifically to solve this case.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-20 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

Oh I just learned that since python3.8 you can name individual tasks. Sorry for 
the confusion :)
It does seem like a good solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-20 Thread Yury Selivanov


Yury Selivanov  added the comment:

> I agree, but wouldn't you agree that some information is better than no 
> information?

We do agree with that. Making it work in the way that does not disturb people 
when a 10mb bytes string is passed is challenging. We could just cut everything 
after 100 characters, but it's not an ideal solution either.

> But in case the same task is run many times with different arguments, the 
> task's name by itself doesn't provide very useful information...

So make it useful. You can concatenate critical arguments reprs to task names 
or make them informative in other way.  If you're working with a third-party 
library that doesn't use task names consider making a PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-20 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

> Not so easy to find a satisfactory generic approach.
I agree, but wouldn't you agree that some information is better than no 
information?

>Task has a name exactly for the purpose of distinguishing similar but 
>different tasks
But in case the same task is run many times with different arguments, the 
task's name by itself doesn't provide very useful information...

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-20 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Not so easy to find a satisfactory generic approach.
An argument can also be 10 MiB length bytes array, a dictionary with 10,000 
elements, HTML page, name it.
All these objects are printable but their representation is too verbose.
Task can have a dozen of arguments, only the latest may be meaningful for 
logically separating one task from others.

Task has a name exactly for the purpose of distinguishing similar but different 
tasks, please use it. Only the task creator knows how to name it better.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-19 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

> This could sometimes make the output verbose

We could limit the length of the recursive __repr__ functions, and display 
partial reprs suffixed with ..., like in numpy for example.

We can define that the maximum wanted length of a task repr would be, say, 80 
characters, get the reprs of all task arguments, and if the sum length is more 
than the maximum we can trim the longest ones and suffix with a '...'.

Maybe this restriction shouldn't be applied if python is built in debug mode.

--
nosy: +kmaork

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-13 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This could sometimes make the output verbose when the arguments themselves are 
tasks while including arguments in the signature in _format_coroutine.

$ cat /tmp/foo.py
import asyncio

async def foo(a, b): pass

async def main():
task = asyncio.create_task(foo(1, b=1))
task1 = asyncio.create_task(foo(1, b=task))
print(repr(task))
print(repr(task1))

asyncio.run(main())

$ python3.8 /tmp/foo.py
>
>

$ ./python.exe /tmp/foo.py
>
>) running at /tmp/foo.py:3>>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
type:  -> behavior
versions: +Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +asyncio
nosy: +asvetlov, yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-13 Thread Stuart Ball


New submission from Stuart Ball :

This is not very helpful if your gather or wait contains multiple versions of 
foo with different argument values: 

``

Should just be:

``

Would probably take all of 5 minutes to implement and make a lot of people's 
lives easier.

--
messages: 361944
nosy: stuball123
priority: normal
severity: normal
status: open
title: __str__ and __repr__ for asyncio.Task still omit arg values

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com