-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_signal_receiver
executable file
·45 lines (36 loc) · 1.44 KB
/
test_signal_receiver
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
#!/usr/bin/env python3
"""
The following scripts, this one included, are used together to debug the signal delivery system:
o test_signal_delivery
o test_signal_receive
o test_signal_send
They are useful because they do not try to catch exceptions and therefore will show any errors
messages. To use, on three different terminals:
1. start test_signal_delivery (never stops).
2. start test_signal_receive (also never stops, but loops doing some work then sleeping
for 5 seconds).
3. Use test_signal_send when test_signal_receive is sleeping. When test_signal_receive
wakes up, it should print "Interrup" before continuing its' work. It ignores interrupts
while working.
To cleanup, kill -9 test_signal_delivery and test_signal_receive.
"""
from cloudscheduler.lib.db_config import Config
from cloudscheduler.lib.signal_functions import *
import signal
import time
config = Config('/etc/cloudscheduler/cloudscheduler.yaml', [], signals=True)
event_receiver_registration(config, 'signal_tests')
while True:
signal.signal(signal.SIGINT, signal.SIG_IGN)
for count in range(100000000):
if count % 10000000 == 0:
print(count)
print('')
signal.signal(signal.SIGINT, config.signals['SIGINT'])
try:
time.sleep(5)
except KeyboardInterrupt:
print('Interrupt')
except Exception as ex:
print(ex)
event_receiver_deregistration(config, 'signal_tests')