We compile the user's code first with a filename, then we only consider frames with frame.f_code.co_filename == our_filename. This removes the need for the hacky checking if in a import thing we did previously.
We specify all raw variables with the prefix raw now (e.g. current_raw_local_variables). Then we only perform operations after we have converted them into our own format (that is JSON-friendly), so that they can be cloned.
Testing
Added testcase to the executor service. Also tested in frontend:
import threading
def worker():
print('Worker thread')
threads = []
for _ in range(5):
t = threading.Thread(target=worker)
threads.append(t)
t.start()
for t in threads:
t.join()
This PR fixes this cloning bug and this frame origin bug.
Fix for cloning bug
We
compile
the user's code first with a filename, then we only consider frames withframe.f_code.co_filename == our_filename
. This removes the need for the hacky checking if in a import thing we did previously.Fix for frame origin bug
We specify all raw variables with the prefix
raw
now (e.g.current_raw_local_variables
). Then we only perform operations after we have converted them into our own format (that is JSON-friendly), so that they can be cloned.Testing
Added testcase to the executor service. Also tested in frontend: