1

I have two apis written using Falcon. First API returns some JSON response. Second API uses First API to get its response. When I independently run First API, I get response but when I use second API, I get a read timeout exception when this second API uses First API call. Any idea ?

localhost:port/firstapi/{123} - Works fine independently.

when loaclhost:port/secondapi uses localhost:port/firstapi/{123}. I get read time out at localhost:port/firstapi/{123}

PS : The two routes are registered in firstapi.py FirstAPIResource class.

1 Answer 1

1

I think you are facing this issue because you are using (running) single instance (Worker).

When you try to call First API from Second API, falcon not able to serve First API as second API is already executing.

So if this is your requirement then try to use (run) multiple instance (Workers).

If you already using Gunicorn with Falcon then try following command:

i.e. Run Gunicorn with 3 workers

gunicorn --workers 3 -b localhost:5000 main:app

And if you are not using Gunicorn then for more information follow this tutorial and this one.

Let me know if you need any further help.

Also as mention in comment, if you are using Windows system then use waitress instead of Gunicorn.

This will run waitress on port 8000 on all available IP addresses, both IPv4 and IPv6.

from waitress import serve
serve(wsgiapp, host='0.0.0.0', port=8000)

Also if you want to use additional parameter like no of thread you can refer this URL

Sign up to request clarification or add additional context in comments.

1 Comment

How can I make use of multiple instances of worker processes at this line of code httpd=simple_server.make_server('127.0.0.1', 8000, app). By the way, windows users use waitress-serve instead of gunicorn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.