Nishant Nawarkhede
Nishant Nawarkhede

Reputation: 8398

global response timeout in django

In django application I am going to receive data from some external applications like facebook , twitter etc. I want to set global response timeout for every request in my app. If there is no response from external applications like facebook , twitter etc in specific time span django should throw an exception for this.

Is there is any way for setting global response timeout in django app ?

Upvotes: 2

Views: 3609

Answers (1)

arocks
arocks

Reputation: 2882

You should never perform URL retrieval synchronously. No matter how low you set your timeouts, there will be always browsers which can timeout earlier based on user setting. The right way to retrieve data from an external site is using asynchronous methods like using Celery.

Within an asynchronous task, you can set the timeout using the Requests library timeout option.

Upvotes: 0

Related Questions