This repository was archived by the owner on Jul 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
38 lines (35 loc) · 1.26 KB
/
Copy pathinit.py
File metadata and controls
38 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import multiprocessing
from main import roadmap
def worker(workQueue, doneQueue):
while True:
job = workQueue.get(True) # warte auf job
# job kann z.B. eine Liste oder ein Dictionary sein, je nachdem, was der Hauptprozess reinschreibt
result = roadmap(job[0], job[1])
doneQueue.put(result, False) # schreibe Ergebnis
def work(currentFrameRecord):
workerCount = 8
doneQueue = multiprocessing.Queue(workerCount)
workQueue = multiprocessing.Queue(workerCount)
instances = []
for i in range(workerCount):
instance = multiprocessing.Process(target=worker, args=(workQueue, doneQueue))
instance.daemon = True
instance.start()
instances.append(instance)
for i in range(workerCount):
job = [i, currentFrameRecord]
workQueue.put(job, False)
result = doneQueue.get(True) # warte auf erstes Ergebnis
for instance in instances:
instance.terminate()
return result
# mach was mit result (restliche Worker laufen weiter, werden aber ignoriert)
currentFrameRecord = 4255 #4409
cycle_count = 1
while(True):
result = work(currentFrameRecord)
if(result[0] < currentFrameRecord):
currentFrameRecord = result[0]
print('cycle {0} done, current record: {1} frames. Record on call {2}.'.format(cycle_count, currentFrameRecord, result[1]))
raw_input()
cycle_count += 1