Random and fork
Julien Le Goff
julien.legoff at gmail.com
Wed Feb 6 17:28:24 CET 2013
Today I came accross a behaviour I did not expect in python (I am using 2.7). In my program, random.random() always seemed to return the same number; it turned out to be related to the fact that I was using os.fork.
See below a small program that illustrates this. It is easily fixed, but I'm interested in knowing why this happens. Can anybody give me a hint? Thanks!
for i in xrange(10):
pid = os.fork()
if pid == 0:
# uncommenting this fixes the problem
More information about the Python-list