31 lines
792 B
Python
31 lines
792 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import multiprocessing
|
|
|
|
# We must import this explicitly, it is not imported by the top-level
|
|
# multiprocessing module.
|
|
import multiprocessing.pool
|
|
import time
|
|
from random import randint
|
|
|
|
|
|
class NoDaemonProcess(multiprocessing.Process):
|
|
def __init__(self, *args, **kwargs):
|
|
super(NoDaemonProcess, self).__init__(**kwargs)
|
|
|
|
# make 'daemon' attribute always return False
|
|
def _get_daemon(self):
|
|
return False
|
|
|
|
def _set_daemon(self, value):
|
|
pass
|
|
|
|
daemon = 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 = NoDaemonProcess
|