A
A
Alena2015-08-06 09:54:18
Python
Alena, 2015-08-06 09:54:18

How to implement an event handler in Python?

There is a task:
The function passes through the base and takes the time from there (Tbase + 6 hours - Tnow), based on this time, the function "falls asleep" for example, for 4 hours 37 minutes. Then the function wakes up, does its business, calculates the sleep time and falls asleep.
Recommend documentation and examples with a similar implementation.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
YaroslavS, 2015-08-06
@Alien-Ka

if you just need the function to fall asleep time.sleep(sleep_time)
if you need an event handler by timer, you are here, there is a good example at the end:
https://docs.python.org/2/library/signal.html

V
Vladimir Martyanov, 2015-08-06
@vilgeforce

In an endless loop, read the time from the database, calculate the sleep time, sleep, complete the desired task, and again at the beginning of the loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question