Note that it may be multithreading vs multiprocessing issue (i.e. as I am not 100% sure I understand what you do, I don't know if multithreading vs multiprocessing should be used). Try using ProcessPoolExecutor instead
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs