Below is my python script.
import multiprocessing
# We must import this explicitly, it is not imported by the top-level
# multiprocessing module.
import multiprocessing.pool
import timefrom random import randintclass NoDaemonProcess(multiprocessing.Process):# make 'daemon' attribute always return Falsedef _get_daemon(self):return Falsedef _set_daemon(self, value):passdaemon = property(_get_daemon, _set_daemon)# We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool
# because the latter is only a wrapper function, not a proper class.
class MyPool(multiprocessing.pool.Pool):Process = NoDaemonProcessdef sleepawhile(t):print("Sleeping %i seconds..." % t)time.sleep(t)return tdef work(num_procs):print("Creating %i (daemon) workers and jobs in child." % num_procs)pool = multiprocessing.Pool(num_procs)result = pool.map(sleepawhile,[randint(1, 5) for x in range(num_procs)])# The following is not really needed, since the (daemon) workers of the# child's pool are killed when the child is terminated, but it's good# practice to cleanup after ourselves anyway.pool.close()pool.join()return resultdef test():print("Creating 5 (non-daemon) workers and jobs in main process.")pool = MyPool(20)result = pool.map(work, [randint(1, 5) for x in range(5)])pool.close()pool.join()print(result)if __name__ == '__main__':test()
This is running in ubuntu server and i'm using python 3.6.7
I had this working properly after apt-get upgrade Im getting error as
group argument must be None for now
What might be the error that I'm facing. Should i change the python version. Should I roll back the changes after upgrading.
EDIT 1
Stacktrace exception:-
Traceback (most recent call last):File "/src/mainapp.py", line 104, in bulkfunp = MyPool(20)File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__self._repopulate_pool()File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_poolself._wrap_exception)File "/usr/lib/python3.6/multiprocessing/pool.py", line 250, in _repopulate_pool_staticwrap_exception)File "/usr/lib/python3.6/multiprocessing/process.py", line 73, in __init__assert group is None, 'group argument must be None for now'
AssertionError: group argument must be None for now
EDIT 2
The code works for python2.7, python3.5 But if i run with python 3.6.7 i got the error as below.
Creating 5 (non-daemon) workers and jobs in main process.
Traceback (most recent call last):File "multi.py", line 52, in <module>test()File "multi.py", line 43, in testpool = MyPool(5)File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__self._repopulate_pool()File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_poolself._wrap_exception)File "/usr/lib/python3.6/multiprocessing/pool.py", line 250, in _repopulate_pool_staticwrap_exception)File "/usr/lib/python3.6/multiprocessing/process.py", line 73, in __init__assert group is None, 'group argument must be None for now'
AssertionError: group argument must be None for now