Issue2202

classification
Title: Current thread renamed to MainThread after a module import
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.gronholm, sbenner, zyasoft
Priority: Keywords:

Created on 2014-09-09.14:51:48 by sbenner, last changed 2015-02-09.23:31:28 by zyasoft.

Messages
msg8978 (view) Author: Sylvain Benner (sbenner) Date: 2014-09-09.14:51:48
Using either interpreter.exec("from x import y") or the org.python.core.imp
msg8981 (view) Author: Alex Grönholm (alex.gronholm) Date: 2014-09-09.18:50:41
Can we get a minimal test case to illustrate the problem?
msg8991 (view) Author: Jim Baker (zyasoft) Date: 2014-09-11.16:49:50
So this seems likely to be a conflict between two usage models: 1) running Jython on its own; 2) using through an API like PythonInterpreter. We should be able to get at some context to differentiate in the threading module that does this rename.
msg9382 (view) Author: Jim Baker (zyasoft) Date: 2015-01-14.02:15:56
It would be useful to keep the thread name set if using the Java API with PythonInterpreter because it's quite useful for debugging.

So here's one possible context that could be used to distinguish. One possible solution is that if the first user thread in Java is always named "main", regardless of the internationalization in the OS, then we could simply check in this setup:

class _MainThread(Thread):
    def __init__(self):
        Thread.__init__(self, name="MainThread")
        import atexit
        atexit.register(self.__exitfunc)

This would then distinguish from Jython as invoked through org.python.util.jython
msg9475 (view) Author: Jim Baker (zyasoft) Date: 2015-02-02.20:31:41
Fixed as of https://hg.python.org/jython/rev/c512d451b76e
History
Date User Action Args
2015-02-09 23:31:28zyasoftsetstatus: pending -> closed
2015-02-02 20:31:41zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg9475
2015-01-14 02:15:57zyasoftsetmessages: + msg9382
2014-09-11 16:49:51zyasoftsetnosy: + zyasoft
messages: + msg8991
2014-09-09 18:50:42alex.gronholmsetnosy: + alex.gronholm
messages: + msg8981
2014-09-09 14:51:48sbennercreate