[Python-Dev] Add function to signal module for getting main thread id (original) (raw)

Andrew Svetlov andrew.svetlov at gmail.com
Fri Aug 30 11:47:04 CEST 2013


I missed _MainThread in threading, that's why I've guessed to add function to signal module. threading.main_thread() is much better sure.

On Fri, Aug 30, 2013 at 12:39 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

Le Fri, 30 Aug 2013 12:24:07 +0300, Andrew Svetlov <andrew.svetlov at gmail.com> a écrit : Main thread is slightly different from others. Signals can be subscribed from main thread only. Tulip has special logic for main thread. In application code we can explicitly know which thread is executed, main or not. But from library it's not easy. Tulip uses check like threading.currentthread().name == 'MainThread' This approach has a problem: thread name is writable attribute and can be changed by user code. Please at least use: >>> isinstance(threading.currentthread(), threading.MainThread) True But really, what we need is a threading.mainthread() function. (Apologies for the previous incomplete reply (keyboard mishap)) Regards Antoine.


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com

-- Thanks, Andrew Svetlov



More information about the Python-Dev mailing list