0

I want to use a python script I have as part of an online service. Let's assume that the script calculates the square root of the input.

For now what I'm doing is:

python my_script.py 4
output: 2

My issue is that the dependencies of the script take several seconds to load, I need to avoid that each time the script is executed. The idea is to have the script running in the background all the time and the execute the sqrt() function when it gets a new input.

Luis Ramon Ramirez Rodriguez
  • 9,591
  • 27
  • 102
  • 181
  • Good idea, but what is your question? – MB-F Apr 24 '17 at 14:14
  • 1
    you should manage your dependencies loading time but for using a python as saas you can create REST Endpoint for that method. Easiest way would be python Flask. Create your python method as a route by specifying URL on it, see python flask....this enables you to get user input via http url and return result to user – BetaDev Apr 24 '17 at 14:18
  • 1
    Possible duplicate of [How to make Python script run as service?](http://stackoverflow.com/questions/16420092/how-to-make-python-script-run-as-service) – Marcos Apr 24 '17 at 14:18
  • @kazemakase what I need to do to make that work, keep the script in the background and send the arguments. – Luis Ramon Ramirez Rodriguez Apr 24 '17 at 14:20
  • How can I manage dependencies loading time ? – Luis Ramon Ramirez Rodriguez Apr 24 '17 at 15:03
  • Write it as a WSGI script, so only gets loaded once and invoked each time there is a web request – Hugh Fisher Apr 24 '17 at 15:05

0 Answers0