Message346720
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()) |
|
| Date |
User |
Action |
Args |
| 2019-06-27 09:23:38 | aldwinaldwin | set | recipients:
+ aldwinaldwin, fabioz, int19h |
| 2019-06-27 09:23:38 | aldwinaldwin | set | messageid: <1561627418.04.0.946333339245.issue37416@roundup.psfhosted.org> |
| 2019-06-27 09:23:38 | aldwinaldwin | link | issue37416 messages |
| 2019-06-27 09:23:37 | aldwinaldwin | create | |
|