0

I am trying to set up a small server providing various functionalities implemented as python scripts. So far, I only wrote scripts so far that I had to run manually, and the result was done once they had finished.

Obviously, I could still implement a script on the OS side to run the actual python script. For instance, a cronjob would be a solution.

However I am now wondering how to implement this behaviour inside the actual python script. Frameworks like Flask for instance can be used to just start a python-based web server and will continue running and answering requests etc. continuously. Or if I where to implement some kind of API with python, I would have to keep this script running permanently to allow api-calls to be received at all time.

So, I wonder how this behaviour is actually implemented using python? I have seen some “easy” solution by basically wrapping the whole script into a never ending while loop, constantly evaluating If statements and this does work, however I imagine this not really the “professional” way to go and might create various problems (memory leak etc.) over time?

MrTony
  • 264
  • 1
  • 12
  • This question is too broad. It would help if you would elaborate on what your python scripts do. Are you trying to implement a web API? Are you creating occasional reports? Do you really mean "continuously" or do you mean periodically? – Jonathon Reinhart Jul 03 '20 at 14:08
  • As I said, continuously, not periodically, e.g. not running a script every 30 minutes etc. None of my scripts does need this functionallity yet, however I wish to learn and build apis for my scripts in the future. Also I am generally curious how to implement a continuously/permanently running script would be implemented. – MrTony Jul 03 '20 at 17:14

0 Answers0