eqcorrscan / RT_EQcorrscan

Real-Time implementation of EQcorrscan methods.
https://rt-eqcorrscan.readthedocs.io/
GNU General Public License v3.0
13 stars 6 forks source link

Run detectors as subprocesses #6

Closed calum-chamberlain closed 4 years ago

calum-chamberlain commented 4 years ago

This PR changes detectors run by a Reactor to run as subprocesses rather than using multiprocessing. No communication is required between the Reactor and the individual detectors, with the Reactor controlling which templates are run by which detector.

New templates are added by writing a new tribe file into the individual detector working directory. The detector checks for this file and reads from it and removes it once it is done. In this way templates can be added to a running detector, while it is running.

As an added advantage, this allows subprocessed detectors to write to their own log-file (which is what I wanted). This keeps logs seperate making it easier to understand what process is doing what. This closes #5

The main reason for doing this was that memory would increase monotonically with the number of detectors running. This was due to the use of os.fork under the hood when spawning new processes. I tried using os.spawn, but ran into some other issues that I forget. os.fork replicates the memory for each new process. This was not ideal.