[Python-Dev] issue 6721 "Locks in python standard library should be sanitized on fork"

Nir Aides nir at winpdb.org
Mon Aug 29 20:29:11 CEST 2011


On Mon, Aug 29, 2011 at 8:16 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>
> On Mon, 29 Aug 2011 13:03:53 -0400 Jesse Noller <jnoller at gmail.com> wrote:
> >
> > Yes; but spawning and forking are both slow to begin with - it's
> > documented (I hope heavily enough) that you should spawn
> > multiprocessing children early, and keep them around instead of
> > constantly creating/destroying them.
>
> I think fork() is quite fast on modern systems (e.g. Linux). exec() is
> certainly slow, though.

On my system, the time it takes worker code to start is:

40 usec with thread.start_new_thread
240 usec with threading.Thread().start
450 usec with os.fork
1 ms with multiprocessing.Process.start
25 ms with subprocess.Popen to start a trivial script.

so os.fork has similar latency to threading.Thread().start, while
spawning is 100 times slower.


More information about the Python-Dev mailing list