File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 2222urlpatterns = [
2323 path ("admin/" , admin .site .urls ),
2424 path ("scheduler/" , include ("scheduler.urls" )),
25- path (
26- "test-view/" ,
27- views .my_view ,
28- ),
25+ path ("test-view/" , views .my_view ),
26+ path ("run-job/" , views .run_job ),
2927]
Original file line number Diff line number Diff line change 1- from django .http . response import HttpResponse
1+ from django .http import HttpResponse
22from django .views .decorators .cache import cache_page
33
4+ from scheduler import job
5+ import time
46
57@cache_page (timeout = 500 )
68def my_view (request ):
79 return HttpResponse ("Yeah" )
10+
11+ @job ("low" )
12+ def long_running_func ():
13+ print ("start the function" )
14+ time .sleep (30 )
15+ print ("function finished" )
16+
17+
18+ def run_job (request ):
19+ if request .method == "GET" :
20+ print ("got a GET-request" )
21+ long_running_func .delay ()
22+ return HttpResponse ("OK - got a GET request" )
23+ return HttpResponse (status = 405 )
You can’t perform that action at this time.
0 commit comments