views:

33

answers:

1

hi lets assume i have a simple programm in python. This programm is running every five minutes throught cron. but i dont know how to write it so the programm will allow to run multiple processes of its self simultaneously. i want to speed things up ...

+1  A: 

I'd handle the forking and process control inside your main python program. Let the cron spawn only a single process and that process be a master for (possible multiple) worker processes.

As for how you can create multiple workers, there's the threading module for multi threading and multiprocessing module for multi processing. You can also keep your actual worker code as separate files and use the subprocess module.

Now that I think about it, maybe you should use supervisord to do the actual process control and simply write the actual work code.

Noufal Ibrahim
i agree but could you let me a hand on this one? some links and recomendations for this would be usefull ... im going blind here
nabizan
The official documentation for the `threading`, `subprocess` and `multiprocessing` module has examples which you can adapt. Give it a shot and post the problems you're having.
Noufal Ibrahim