0

I am currently starting to work on a web server running web.py . If I understand it correctly, the whole thing is implemented as some kind of a loop that listens to the requests at the specified port and reacts accordingly.

I would like the server to perform a certain action at a certain time without a request that triggers it. What is the best way to achieve this? Thank you.

fedorSmirnov
  • 691
  • 2
  • 9
  • 19

2 Answers2

1

I think the best way is to set up a cron job in the system, which will execute your script (which can be written in Python or other language).

Tae
  • 1,633
  • 5
  • 28
  • 44
1

If you want to run it within python you can look at using the threading class.

More information on how to do it here: Executing periodic actions in Python

Community
  • 1
  • 1
Rico
  • 53,863
  • 12
  • 97
  • 127