0

I have a Python Web App defined using connexion[swagger-ui], on my my_app.py file:

if __name__ == '__main__':
    # run our standalone gevent server
    application.run(server='gevent', port=8080)

Now, I have another python file, test.py that is always calling an API in order to get some data:

def f():
    while True:
        ... # Call API and handles data

Both on the same project. Now, I was trying some approaches as multiprocessing package, to have those tasks running without blocking each other, but without success. Is there any suggestion or best approach to implement this?

gr7
  • 492
  • 3
  • 11
  • Linux and Windows allow multitasking, i.e. multiple processes can run concurrently. Just run the two as separate processes, e.g. from the shell. Note: in case it's a unit test, there is normally no need for two separate processes: all you need is a test client that short-circuits the HTTP requests to the handlers of the framework (I have never used the one you mention l) – Pynchia Sep 11 '19 at 18:28
  • If `connexion` is a Flask extension, you can use Flask's [test client](https://werkzeug.palletsprojects.com/en/0.15.x/test/#werkzeug.test.Client) – Pynchia Sep 11 '19 at 18:33
  • Both process are running on a docker container. – gr7 Sep 11 '19 at 18:50
  • @Pynchia Thanks. I could start both process on the same container by following some information provided in another [post](https://stackoverflow.com/questions/53920742/how-to-run-multiple-python-scripts-and-an-executable-files-using-docker). It's is more related to Docker than Multi-threading. Now I'm just starting both processes on the same container. I know that the best approach would be to have two separated containers, but for what I pretend now this is enough. – gr7 Sep 11 '19 at 19:13

0 Answers0