[Python-Dev] Add function to signal module for getting main thread id (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Fri Aug 30 11:39:37 CEST 2013
- Previous message: [Python-Dev] Add function to signal module for getting main thread id
- Next message: [Python-Dev] Add function to signal module for getting main thread id
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.current_thread(), threading._MainThread) True
But really, what we need is a threading.main_thread() function.
(Apologies for the previous incomplete reply (keyboard mishap))
Regards
Antoine.
- Previous message: [Python-Dev] Add function to signal module for getting main thread id
- Next message: [Python-Dev] Add function to signal module for getting main thread id
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]