forked from ansible/dispatcherd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethods.py
54 lines (33 loc) · 1.08 KB
/
methods.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
from dispatcher.publish import task
@task(queue='test_channel')
def sleep_function(seconds=1):
time.sleep(seconds)
@task(queue='test_channel', on_duplicate='discard')
def sleep_discard(seconds=1):
time.sleep(seconds)
@task(queue='test_channel', on_duplicate='serial')
def sleep_serial(seconds=1):
time.sleep(seconds)
@task(queue='test_channel', on_duplicate='queue_one')
def sleep_queue_one(seconds=1):
time.sleep(seconds)
@task(queue='test_channel')
def print_hello():
print('hello world!!')
@task(queue='test_channel', bind=True)
def hello_world_binder(binder):
print(f'Values in binder {vars(binder)}')
print(f'Hello world, from worker {binder.worker_id} running task {binder.uuid}')
@task(queue='test_channel', timeout=1)
def task_has_timeout():
time.sleep(5)
def get_queue_name():
return 'test_channel'
@task(queue=get_queue_name)
def use_callable_queue():
print('sucessful run using callable queue')
@task(queue=get_queue_name)
class RunJob:
def run(self):
print('successful run using callable queue with class')