projects
/
cmccabe-bin
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
811a939
)
pickrand.py: seed RNG with process ID
author
Colin Patrick McCabe
<cmccabe@alumni.cmu.edu>
Fri, 10 Feb 2012 06:00:27 +0000 (22:00 -0800)
committer
Colin Patrick McCabe
<cmccabe@alumni.cmu.edu>
Fri, 10 Feb 2012 06:00:27 +0000 (22:00 -0800)
Seed the random number generator with the current process ID rather than
with the clock.
Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
pickrand.py
patch
|
blob
|
history
diff --git
a/pickrand.py
b/pickrand.py
index
558115c
..
6340971
100755
(executable)
--- a/
pickrand.py
+++ b/
pickrand.py
@@
-20,7
+20,7
@@
for root, dirs, files in os.walk("."):
allfiles.append(os.path.join(root, f))
if (len(allfiles) == 0):
sys.exit(1)
-random.seed(None)
+random.seed(os.getpid())
r = random.randint(0,len(allfiles) - 1)
print(allfiles[r])
if (print_to_stderr):