Following the code:
1. #%% Start Mustard
2. cwd = os.getcwd()
3. import threading
4. import mustard
5. app = mustard.Mustard()
6. thread = threading.Thread(target=app.run)
7. thread.daemon = True
8. thread.start()
9.
10. #%% Once mustard is open, undo the change of working directory
11. os.chdir(cwd)
12. del cwd
It saves the current work dir (cdw) (line 2), and starts mustard (lines 3 to 8). After that it resets the cwd (lines 10 to 12).
On line 10 there is this code block separator. If I try to run the two blocks together, it bugs. If I run the first, it finishes loading mustard without problems, then I run the second without problems.
Seems like mustard is being initialized by a thread which is not locking the cwd, and it changes while loading, causing bugs.
Also, I am not clear why "import mustard" changes the cwd
Following the code:
It saves the current work dir (cdw) (line 2), and starts mustard (lines 3 to 8). After that it resets the cwd (lines 10 to 12).
On line 10 there is this code block separator. If I try to run the two blocks together, it bugs. If I run the first, it finishes loading mustard without problems, then I run the second without problems.
Seems like mustard is being initialized by a thread which is not locking the cwd, and it changes while loading, causing bugs.
Also, I am not clear why "import mustard" changes the cwd