I wrote a very simple script to play around with multiprocessing:
import multiprocessing
import time
def func1(d):
while d['message'] != 'kill':
print(d['message'])
print('done')
def func2(d):
for i in range(60):
time.sleep(1)
d['message'] = 'Message ' + str(i)
d['message'] = 'kill'
if __name__ == '__main__':
mgr = multiprocessing.Manager()
d = mgr.dict()
d['message'] = 'Waiting...'
print(d['message'])
proc1 = multiprocessing.Process(target=func1,args=(d,))
proc2 = multiprocessing.Process(target=func2,args=(d,))
proc1.start()
proc2.start()
When I run this a get the following error:
Process Process-2:
Traceback (most recent call last):
File "C:\Python34\lib\multiprocessing\managers.py", line 724, in _callmethod
conn = self._tls.connection
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'
I've seen some people having similar problems because they've given files the same names as the modules being referenced by the standard library, but I've only written one .py file!