-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.py
executable file
·32 lines (22 loc) · 792 Bytes
/
main.py
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
from microWorkers import MicroWorkers
from time import sleep
print()
def jobA(jobName, jobArg) :
sleep(1)
return '%s:OK:1s' % jobName
def jobB(jobName, jobArg) :
sleep(2)
return '%s:OK:2s' % jobName
def jobC(jobName, jobArg) :
sleep(3)
return '%s:OK:3s' % jobName
def jobFinished(jobName, jobArg, jobResult) :
print('Job %s finished (%s)' % (jobName, jobResult))
workers = MicroWorkers(workersCount=5)
for x in range(5) :
workers.AddJob('JobA.%s' % x, jobA, arg=None, onFinished=jobFinished)
workers.AddJob('JobB.%s' % x, jobB, arg=None, onFinished=jobFinished)
workers.AddJob('JobC.%s' % x, jobC, arg=None, onFinished=jobFinished)
# Waiting end of all jobs,
while workers.IsWorking :
sleep(0.100)