Add a lock

There was a blocking problem when opening multiple sub_processes.
Adding a lock resolved the problem.