nartes <[email protected]> added the comment:
https://gist.github.com/efe828a7bbac97e02a7d83d2a2d78540
import io
import os
import sys
import multiprocessing
class B(multiprocessing.Process):
@classmethod
def _my_thread(self, a, b):
print("Class method as a separate process entry point. (%s, %s)" % (a,
b))
def __init__(self, glock, *args, **kwargs):
multiprocessing.Process.__init__(self, *args, **kwargs)
self.glock = glock
def run(self):
try:
sys.stdin = os.fdopen(0, 'r')
sys.stdout = os.fdopen(1, 'w')
self._run()
except Exception as e:
raise e
finally:
print("Sort of a process destructor, PID = %s" % os.getpid())
for s in [sys.stdin, sys.stdout]:
if s is not None and\
hasattr(s, 'close'):
s.close()
def _run(self):
print("Hello, World!")
class A:
def __init__(self):
self.glock = multiprocessing.Lock()
def run(self):
jobs = []
for k in range(3):
jobs.append(B(self.glock))
#jobs.append(B(self.glock, None, None, None))
jobs.append(multiprocessing.Process(
target=B._my_thread,
args=("one", "two")))
for j in jobs:
j.start()
for j in jobs:
j.join()
if __name__ == '__main__':
A().run()
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32184>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com