i see a lot of examples of how to use multiprocessing but they all talk about spawning workers and controlling them while the main process is alive. my question is how to control background workers in the following way:
start 5 worker from command line:
- manager.py --start 5
after that, i will be able to list and stop workers on demand from command line:
- manager.py --start 1 #will add 1 more worker
- manager.py --list
- manager.py --stop 2
- manager.py --sendmessagetoall "hello"
- manager.py --stopall
the important point is that manager.py should exit after every run. what i don't understand is how to get a list of already running workers from an newly created manager.py program and communicate with them.
edit: Bilkokuya suggested that i will have (1)a manager process that manage a list of workers... and will also listen to incoming commands. and (2) a small command line tool that will send messages to the first manager process... actually it sounds like a good solution. but still, the question remains the same - how do i communicate with another process on a newly created command line program (process 2)? all the examples i see (of Queue for example) works only when both processes are running all the time