3

How can I set a time limit for execution of a django view. i.e. a view never takes more than say, 10secs for execution and if it does, it should return half way from execution. My idea is that we can have a decorator. But i am not sure. Looking for a solution. Thanks in advance.

Anshuma
  • 3,242
  • 2
  • 16
  • 14
  • 1
    Oh look! Over here --> http://stackoverflow.com/questions/492519/timeout-on-a-python-function-call – Thomas Apr 12 '12 at 09:19

1 Answers1

0

I would suggest to consider using Celery, which includes built in time limit support for tasks, and would keep your django app and server responsive:

A single task can potentially run forever, if you have lots of tasks waiting for some event that will never happen you will block the worker from processing new tasks indefinitely. The best way to defend against this scenario happening is enabling time limits.

Udi
  • 29,222
  • 9
  • 96
  • 129