This script provides a consistent environment for services to run in. The basic architecture is:
- parent process (python, ipython, etc.)
- this process, referred to as the "current" process (service/main.py)
- child process (the service)
- (optional): any child processes that the service creates
- clients (any other Python processes that are using this service) - see below
Some services that we spin up do not terminate on their own when their parent process terminates, so they need to be killed explicitly. However, if the parent process is a Python interpreter that is in the process of shutting down, it cannot reliably kill its children. This script works around these issues by detecting when the parent process exits, terminating its children, and only then exiting itself.
Some services can also only have a single running instance per user. Notably, only one instance of MongoDB can use a given data folder. To support this, when invoked with the "--multi" option, this script allows additional "clients", i.e. other Python processes using FiftyOne, to register themselves at any time. This script will continue running in the background and keep the child process alive until all registered clients, including the original parent process, have exited.
Class |
|
Monitor for an output stream (stdout or stderr) of a child process. |
Class |
|
Monitor to keep track of all clients using this service. |
Class |
|
Undocumented |
Function | monitor |
Trigger shutdown when the parent process closes this process's stdin. This will occur if the fiftyone.core.service.DatabaseService singleton destroyed. |
Function | shutdown |
Kill subprocesses and wait for them to finish. |
Function | start |
Undocumented |
Function | trigger |
Start the shutdown process. |
Variable | args |
Undocumented |
Variable | child |
Undocumented |
Variable | child |
Undocumented |
Variable | child |
Undocumented |
Variable | client |
Undocumented |
Variable | command |
Undocumented |
Variable | exit |
Undocumented |
Variable | exiting |
Undocumented |
Variable | lock |
Undocumented |
Variable | parser |
Undocumented |
Variable | popen |
Undocumented |
Variable | stdin |
Undocumented |
Trigger shutdown when the parent process closes this process's stdin.
This will occur if the fiftyone.core.service.DatabaseService
singleton destroyed.
This should only occur when the parent process has exited.