MCPcopy
hub / github.com/rq/django-rq / get_job_class

Function get_job_class

django_rq/jobs.py:8–25  ·  view source on GitHub ↗

Return job class from RQ settings, otherwise return Job. If `job_class` is not None, it is used as an override (can be python import path as string).

(job_class: Optional[Union[str, type[Job]]] = None)

Source from the content-addressed store, hash-verified

6
7
8def get_job_class(job_class: Optional[Union[str, type[Job]]] = None) -> type[Job]:
9 """
10 Return job class from RQ settings, otherwise return Job.
11 If `job_class` is not None, it is used as an override (can be
12 python import path as string).
13 """
14 RQ = getattr(settings, 'RQ', {})
15
16 if not job_class:
17 job_class = RQ.get('JOB_CLASS')
18
19 # Ensure we never have None (in case someone explicitly sets JOB_CLASS to None)
20 if not job_class:
21 job_class = Job
22
23 if isinstance(job_class, str):
24 job_class = cast(type[Job], import_attribute(job_class))
25 return job_class

Callers 7

test_custom_classMethod · 0.90
test_local_overrideMethod · 0.90
get_queueFunction · 0.85
get_queuesFunction · 0.85
get_workerFunction · 0.85
handleMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_custom_classMethod · 0.72
test_local_overrideMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…