Towards django RQ
This commit is contained in:
13
app_urls/api/tasks.py
Normal file
13
app_urls/api/tasks.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django_rq import job
|
||||
import time
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@job
|
||||
def task_1(message):
|
||||
logger.info("Message: {}".format(message))
|
||||
try:
|
||||
time.sleep(5) # Simulate a long-running task
|
||||
print(f"Task completed: {message}")
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
Reference in New Issue
Block a user