The current PIIDigger lacks a consistent way to start up and shutdown the processes. This makes events like KeyboardInterrupt difficult to manage and results in the occasional hang while trying to shutdown from unexpected events.
Use Case
As a user, the shutdown process should be better managed to ensure a consistent end to the program, especially when unexpected events are handled.
Requirements
A process manager class should manage the following:
register -- Register a new type of process
start -- Start the processes in a defined order
wait_for_procsses -- Monitor the processes for completion by using join
terminate_all_processes -- Terminate all processes if a KeyboardInterrupt exception is triggered
Inputs
register
The register method should accept the following inputs:
target -- The callable that will be run
start_order -- The expected startup sequence
num_processes -- The number of required processes
args -- The arguments required by target
The register method will also keep track of each of the processes that will be started, so that it can manage them later.
start
No inputs are required for this method.
The start method will start each sub-process in the order defined in start_order. A shutdown_order will be defined which can be used by wait_for_processes and terminate_all_processes to effect an orderly shutdown.
start should be callable multiple times and keep track of processes that have already been started.
wait_for_processes
No inputs are required
terminate_all_processes
No inputs are required.
Outputs
No outputs are expected other than typical Python behavior when instantiating a new instance of the class.
Problem
The current PIIDigger lacks a consistent way to start up and shutdown the processes. This makes events like KeyboardInterrupt difficult to manage and results in the occasional hang while trying to shutdown from unexpected events.
Use Case
As a user, the shutdown process should be better managed to ensure a consistent end to the program, especially when unexpected events are handled.
Requirements
A process manager class should manage the following:
register
-- Register a new type of processstart
-- Start the processes in a defined orderwait_for_procsses
-- Monitor the processes for completion by usingjoin
terminate_all_processes
-- Terminate all processes if a KeyboardInterrupt exception is triggeredInputs
register
The
register
method should accept the following inputs:target
-- The callable that will be runstart_order
-- The expected startup sequencenum_processes
-- The number of required processesargs
-- The arguments required bytarget
The
register
method will also keep track of each of the processes that will be started, so that it can manage them later.start
No inputs are required for this method.
The
start
method will start each sub-process in the order defined instart_order
. Ashutdown_order
will be defined which can be used bywait_for_processes
andterminate_all_processes
to effect an orderly shutdown.start
should be callable multiple times and keep track of processes that have already been started.wait_for_processes
No inputs are required
terminate_all_processes
No inputs are required.
Outputs
No outputs are expected other than typical Python behavior when instantiating a new instance of the class.