Skip to content

Commit 14fc6c3

Browse files
committed
fix:method for testing multi-process
1 parent bc881f0 commit 14fc6c3

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

testproject/testproject/urls.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
urlpatterns = [
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
]

testproject/testproject/views.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
from django.http.response import HttpResponse
1+
from django.http import HttpResponse
22
from django.views.decorators.cache import cache_page
33

4+
from scheduler import job
5+
import time
46

57
@cache_page(timeout=500)
68
def 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)

0 commit comments

Comments
 (0)