Files
h2inc-old/Multiprocessing test/mp_class.py
2018-05-17 21:44:45 +02:00

31 lines
761 B
Python

#!/usr/bin/env python3.5
import multiprocessing
class Listener(multiprocessing.Threading):
def __init__(self.response):
multiprocessing.Threading.__init__(self)
self.response = response
def run(self):
while True:
r = self.responce.get()
if r is None:
break
print(r)
self.response.task_done()
self.response.task_done()
return
class Worker(multiprocessing.Process):
def __init__(self.workload):
mulitiprocessing.Process.__init__(self)
self.workload = workload
def run(self):
while True:
n = self.workload.get()
print(n*n)
self.workload.task_done()
work = [range(10)]
print(work)