Created
May 7, 2014 10:23
-
-
Save andrewbolster/540ca79f01c337d095a8 to your computer and use it in GitHub Desktop.
Code Samples for os.nice post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# 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