-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdebug_web.py
More file actions
32 lines (23 loc) · 1020 Bytes
/
debug_web.py
File metadata and controls
32 lines (23 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import urllib.parse
from django.shortcuts import reverse
from ..job import Job
from .base import BaseBackend
from ..types import QueueName, WorkerNumber
from ..app_settings import app_settings
class DebugWebBackend(BaseBackend):
"""
This backend aids debugging in concert with the 'debug-run' view.
Instead of actually running a job, it prints the url to the debug-run view
for the local Django instance which can be used to run the task for
debugging.
See the docstring of that view for information (and limitations) about it.
"""
def enqueue(self, job: Job, queue: QueueName) -> None:
path = reverse('django_lightweight_queue:debug-run')
query_string = urllib.parse.urlencode({'job': job.to_json()})
url = "{}{}?{}".format(app_settings.SITE_URL, path, query_string)
print(url)
def dequeue(self, queue: QueueName, worker_num: WorkerNumber, timeout: float) -> None:
pass
def length(self, queue: QueueName) -> int:
return 0