equal
deleted
inserted
replaced
1 # -*- coding: utf-8 -*- |
1 # -*- coding: utf-8 -*- |
2 # Worker code |
2 # Worker code |
3 |
3 |
4 from multiprocessing import Process |
4 from multiprocessing import Process |
|
5 import logging |
5 import time |
6 import time |
6 |
7 |
7 class Worker(Process): |
8 class Worker(Process): |
8 def __init__(self,queue): |
9 def __init__(self,queue): |
9 Process.__init__(self) |
10 Process.__init__(self) |
10 self.queue=queue |
11 self.queue=queue |
11 |
12 |
12 def run(self): |
13 def run(self): |
|
14 logging.info('Worker thread läuft nun...') |
|
15 id=0 |
13 while 1: |
16 while 1: |
14 job=self.queue.get() |
17 job=self.queue.get() |
15 if job is None: |
18 if job is None: |
16 break # reached end of queue |
19 break # reached end of queue |
17 job.start() |
20 id+=1 |
|
21 logging.info('ein neuer Job(%d)' %(id)) |
|
22 try: |
|
23 job.start(id) |
|
24 logging.info('Job(%d) fertig ;)'%(id)) |
|
25 except: |
|
26 logging.exception('Job(%d) fehlgeschlagen :('%(id)) |