2013/8/30 Andrew Svetlov <andrew.svet...@gmail.com>: > Tulip uses check like > threading.current_thread().name == 'MainThread'
You should use the identifier, not the name: threading.current_thread().ident. > This approach has a problem: thread name is writable attribute and can > be changed by user code. The ident attribute cannot be modified. > My proposition is to add function like get_mainthread_id() -> int > which return ident for main thread (I know function name is not > perfect, please guess better one). Just call threading.get_ident() at startup, when you have only one thread (the main thread). There is an ugly hack to get the identifier of the main thread: threading._shutdown.__self__.ident. > Signal module already has required data as internal variable > static long main_thread; > I just guess to expose this value to python. > Thoughts? If we expose the identifier of the main thread, something should be added to the threading module, not the signal module. Is it possible that the main thread exit while there are still other live threads? Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com