Python os.fork1() Examples
The following are 10
code examples of os.fork1().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: fork_wait.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread = threading.Thread(target=self.f, args=(i,)) thread.start() self.threads.append(thread) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid)
Example #2
Source File: fork_wait.py From BinderFilter with MIT License | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die
Example #3
Source File: fork_wait.py From oss-ftp with MIT License | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die
Example #4
Source File: fork_wait.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): _thread.start_new(self.f, (i,)) # busy-loop to wait for threads deadline = time.monotonic() + 10.0 while len(self.alive) < NUM_THREADS: time.sleep(0.1) if deadline < time.monotonic(): break a = sorted(self.alive.keys()) self.assertEqual(a, list(range(NUM_THREADS))) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent try: self.wait_impl(cpid) finally: # Tell threads to die self.stop = 1
Example #5
Source File: fork_wait.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): _thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = sorted(self.alive.keys()) self.assertEqual(a, list(range(NUM_THREADS))) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent try: self.wait_impl(cpid) finally: # Tell threads to die self.stop = 1
Example #6
Source File: fork_wait.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die
Example #7
Source File: fork_wait.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): _thread.start_new(self.f, (i,)) # busy-loop to wait for threads deadline = time.monotonic() + 10.0 while len(self.alive) < NUM_THREADS: time.sleep(0.1) if deadline < time.monotonic(): break a = sorted(self.alive.keys()) self.assertEqual(a, list(range(NUM_THREADS))) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent try: self.wait_impl(cpid) finally: # Tell threads to die self.stop = 1
Example #8
Source File: fork_wait.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEquals(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die
Example #9
Source File: fork_wait.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die
Example #10
Source File: fork_wait.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_wait(self): for i in range(NUM_THREADS): thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) a = self.alive.keys() a.sort() self.assertEqual(a, range(NUM_THREADS)) prefork_lives = self.alive.copy() if sys.platform in ['unixware7']: cpid = os.fork1() else: cpid = os.fork() if cpid == 0: # Child time.sleep(LONGSLEEP) n = 0 for key in self.alive: if self.alive[key] != prefork_lives[key]: n += 1 os._exit(n) else: # Parent self.wait_impl(cpid) # Tell threads to die self.stop = 1 time.sleep(2*SHORTSLEEP) # Wait for threads to die