Skip to content

Instantly share code, notes, and snippets.

@andrewbolster
Created May 7, 2014 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewbolster/540ca79f01c337d095a8 to your computer and use it in GitHub Desktop.
Save andrewbolster/540ca79f01c337d095a8 to your computer and use it in GitHub Desktop.
Code Samples for os.nice post
import os
...
def thread_mask(args):
# Properly Parallel RNG
#http://stackoverflow.com/questions/444591/convert-a-string-of-bytes-into-an-int-python
myid=current_process()._identity[0]
np.random.seed(myid^struct.unpack("<L",os.urandom(4))[0])
os.nice(5)
return long_simulation(args)
...
# Be Nice
niceness=os.nice(0)
os.nice(5-niceness)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment