While working on multiprocessing the fo Python subprocess wrappers, I was getting errors that the /tmp/mpc_obs.txt file was missing for some of the concurrently running processes. It turns out each fo process was working on the same temporary observation file which was causing issues.
Here is an example from my Python wrapper, the second statement is a stderr output from fo:
(pid=135436) Find_Orb call complete.
(pid=135436) Couldn't locate the file '/tmp/temp_obs.txt'
This PR contains a relatively simple fix to randomly generate a temp_obs file using a template string. This fix avoids the issue with multiple threads working on the sample temporary file. I have tested the change on my multiprocessed wrapper and thus far have not encountered any more issues.
Note: the compiler now warns that using mkstemp is better than mktemp. From my understanding of the code, swapping to mkstemp would involve making more changes than I am comfortable making (mkstemp creates the temporary file while mktemp creates the file's name).
While working on multiprocessing the
fo
Python subprocess wrappers, I was getting errors that the /tmp/mpc_obs.txt file was missing for some of the concurrently running processes. It turns out eachfo
process was working on the same temporary observation file which was causing issues.Here is an example from my Python wrapper, the second statement is a stderr output from
fo
:This PR contains a relatively simple fix to randomly generate a temp_obs file using a template string. This fix avoids the issue with multiple threads working on the sample temporary file. I have tested the change on my multiprocessed wrapper and thus far have not encountered any more issues.
Note: the compiler now warns that using
mkstemp
is better thanmktemp
. From my understanding of the code, swapping tomkstemp
would involve making more changes than I am comfortable making (mkstemp
creates the temporary file whilemktemp
creates the file's name).