Ubuntu 10.04 - Python Multiprocessing - object 'module' does not have attribute 'local' error

The following code is from the python 2.6 manual.

from multiprocessing import Process
import os

def info(title):
    print(title)
    print('module name:', 'me')
    print('parent process:', os.getppid())
    print('process id:', os.getpid())

def f(name):
    info('function f')
    print('hello', name)

if __name__ == '__main__':
    info('main line')
    p = Process(target=f, args=('bob',))
    p.start()
    p.join()

This creates the following stack traces:

Traceback (most recent call last):
  File "threading.py", line 1, in <module>
    from multiprocessing import Process
  File "/usr/lib/python2.6/multiprocessing/__init__.py", line 64, in <module>
    from multiprocessing.util import SUBDEBUG, SUBWARNING
  File "/usr/lib/python2.6/multiprocessing/util.py", line 287, in <module>
    class ForkAwareLocal(threading.local):
AttributeError: 'module' object has no attribute 'local'
Exception AttributeError: '_shutdown' in <module 'threading' from '/home/v0idnull/tmp/pythreads/threading.pyc'> ignored
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
    info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
    info('process shutting down')
TypeError: 'NoneType' object is not callable

I absolutely do not know why this is happening, and google gave me very little work.

+3
source share
1 answer

this code works fine on my machine:
Ubuntu 10.10, Python 2.6.6 64-bit.

, threading.py, (. ). , "" . , "threading.py", .

... Python 2.6... Python 3.x. , , , .

+4

Source: https://habr.com/ru/post/1769272/


All Articles