This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aldwinaldwin
Recipients aldwinaldwin, fabioz, int19h
Date 2019-06-27.09:23:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561627418.04.0.946333339245.issue37416@roundup.psfhosted.org>
In-reply-to
Content
The second import actually doesn't happen. You need to reload it. This can be tested by putting print('loading threading') in threading.py.

Your first method-thread will still think it's main thread. So no idea if this is a bug or wrong use. 'import threading' should be one of the first lines in your main code/thread?


import _thread
import time
import importlib
barrier = 0

def method():
    import threading  # Will make threading the wrong thread.
    global barrier
    print(threading.main_thread())
    print(threading.current_thread())
    barrier = 1

_thread.start_new_thread(method, ())

while barrier != 1:
    time.sleep(.1)

import threading
importlib.reload(threading)
print(threading.main_thread())
print(threading.current_thread())
History
Date User Action Args
2019-06-27 09:23:38aldwinaldwinsetrecipients: + aldwinaldwin, fabioz, int19h
2019-06-27 09:23:38aldwinaldwinsetmessageid: <1561627418.04.0.946333339245.issue37416@roundup.psfhosted.org>
2019-06-27 09:23:38aldwinaldwinlinkissue37416 messages
2019-06-27 09:23:37aldwinaldwincreate