Skip to content

Commit c1fb95f

Browse files
committed
Set delay to 5sec for max wait before exit
1 parent cc82f1c commit c1fb95f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

library/scheduler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ def DiskStats():
125125
@async_job("Queue_Handler")
126126
@schedule(timedelta(milliseconds=1).total_seconds())
127127
def QueueHandler():
128+
# Do next action waiting in the queue
128129
global STOPPING
129-
130130
if STOPPING:
131-
# Empty the message queue to allow program to exit cleanly
131+
# Empty the action queue to allow program to exit cleanly
132132
while not config.update_queue.empty():
133133
f, args = config.update_queue.get()
134134
f(*args)

main.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@
2121
if __name__ == "__main__":
2222

2323
def sighandler(signum, frame):
24-
print(" Caught signal ", str(signum), ", exiting")
24+
print(" Caught signal", str(signum), ", exiting")
2525

2626
# Do not stop the program now in case data transmission was in progress
27-
# Instead, ask the scheduler to finish its current task before stopping
27+
# Instead, ask the scheduler to empty the action queue before stopping
2828
scheduler.STOPPING = True
2929

30-
print("Waiting for all pending request to be sent to display...")
30+
# Allow 5 seconds max. delay in case scheduler is not responding
31+
wait_time = 5
32+
print("Waiting for all pending request to be sent to display (%ds max)..." % wait_time)
3133

32-
# Allow 2 seconds max. delay in case scheduler is not responding
33-
wait_time = 2
3434
while not scheduler.is_queue_empty() and wait_time > 0:
3535
time.sleep(0.1)
3636
wait_time = wait_time - 0.1
3737

38+
print("(%.1fs)" % (5 - wait_time))
39+
3840
# We force the exit to avoid waiting for other scheduled tasks: they may have a long delay!
3941
try:
4042
sys.exit(0)

0 commit comments

Comments
 (0)