Message270329
On Ubuntu 16.04
python '3.5.1+ (default, Mar 30 2016, 22:46:26) \n[GCC 5.3.1 20160330]'
The following code prints "hi" 4 times:
import multiprocessing
import time
import threading
class dumb(threading.Thread):
def __init__(self):
super(dumb, self).__init__()
def run(self):
while True:
print("hi")
time.sleep(1)
def test():
for i in range(2):
bar = dumb()
bar.start()
def main():
p = []
for i in range(2):
p.append(multiprocessing.Process(target=test))
for i in p:
i.start()
for i in p:
i.join()
if __name__ == '__main__':
main()
Note: The above code runs fine on Python 3.5.2 (64-bit) on Windows 10
Joining the threads in test fixes the problem:
def test():
p = []
for i in range(2):
bar = dumb()
bar.start()
p.append(bar)
for i in p:
i.join() |
|
Date |
User |
Action |
Args |
2016-07-13 17:20:48 | JA | set | recipients:
+ JA |
2016-07-13 17:20:48 | JA | set | messageid: <1468430448.11.0.0781111425971.issue27508@psf.upfronthosting.co.za> |
2016-07-13 17:20:48 | JA | link | issue27508 messages |
2016-07-13 17:20:48 | JA | create | |
|