asyncio icon indicating copy to clipboard operation
asyncio copied to clipboard

Tulip thread/process name analogue

Open GoogleCodeExporter opened this issue 10 years ago • 4 comments

This is a feature request, not a bug.

Thread names are a common logging aide in Python and other mainstream 
languages. Since a particular Tulip event loop is inherently single threaded, 
yet can still multiplex complex independent activities I propose a mechanism to 
assign names to Tulip's thread analogues - Tasks/coroutines. This information 
should then be accessible in some way by logger instances.

This should maybe be designed in a way that is useful to other async event loop 
implementations, such as Twisted and Tornado?

Guido has expressed interest in the idea, but maybe not in the first release.


Original issue reported on code.google.com by [email protected] on 6 Oct 2013 at 1:09

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

Note that the name of the function used to start a Task is in its repr(). Maybe 
the main missing thing is something that gets the current Task? Although I'm 
not sure what to do if what's running didn't come from a task but is a handler 
scheduled by e.g. call_soon().

Original comment by [email protected] on 8 Oct 2013 at 11:31

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

Original comment by [email protected] on 16 Oct 2013 at 4:42

  • Added labels: Priority-Low
  • Removed labels: Priority-Medium

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

We now have a class method Task.current_task() which you can use for this.

Original comment by [email protected] on 5 Dec 2013 at 11:36

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

Task.current_task() is analogous to threading.current_thread. The next step is 
the analogue of threading.Thread.name.

The repr() might be the start of the solution, but we still need a counter to 
disambiguate further (just like threading.Threads do). Maybe set the name at 
creation time to "repr()-N"? The counter should probably be per-process instead 
of per-loop too.

Original comment by [email protected] on 23 Feb 2014 at 1:14

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter