There is a script that represents a bot for Telegram. Two functions that perform different tasks.
The first one responds to user requests (instantly), the other notifies users when news appears on the site, periodically requesting the page content (also instantly), but it has a timeout (do not poll the site every second, right?), So they cannot be executed sequentially.
In addition to using the threading module and running one of the functions in daemon mode, I did not find another solution. Is it too much to use such a module just to start a simple daemon function?
import threading from time import sleep def function1(): ... sleep(timeout) def function2(): ... t = threading.Thread(target=function1) t.daemon = True t.start() function2()