Example #1
0
    def fork(self, name):
        pid = os.fork()
        assert pid != -1
        if pid == 0:
            self.d_parentProcess = False
            # set seeds different for each child
            if "random" in sys.modules:
                import random

                random.seed()
            if "numpy.random" in sys.modules:
                import numpy.random

                numpy.random.seed()
            if "pcraster" in sys.modules:
                import pcraster

                pcraster.setrandomseed(0)
            # # for backwards compatibility
            # if "pcraster" in sys.modules:
            #   import PCRasterPython
            #   PCRasterPython.setrandomseed(0)
        else:
            self.d_childProcesses.append(ChildProcess(name, pid))
            self.d_nrForkedChildProcesses += 1
        return pid
Example #2
0
 def fork(self, name):
     pid = os.fork()
     assert pid != -1
     if pid == 0:
         self.d_parentProcess = False
         # set seeds different for each child
         if "random" in sys.modules:
             import random
             random.seed()
         if "numpy.random" in sys.modules:
             import numpy.random
             numpy.random.seed()
         if "pcraster" in sys.modules:
             import pcraster
             pcraster.setrandomseed(0)
         # # for backwards compatibility
         # if "pcraster" in sys.modules:
         #   import PCRasterPython
         #   PCRasterPython.setrandomseed(0)
     else:
         self.d_childProcesses.append(ChildProcess(name, pid))
         self.d_nrForkedChildProcesses += 1
     return pid
Example #3
0
 def setUp(self):
   _pcraster._initGlobals()
   pcraster.setrandomseed(1)