django-q
django-q copied to clipboard
Error after background task runs on DjangoQ
I am getting an error after my background task runs in djangoQ
Function:
def welcome_mail(): body_to_sent = 'holaa' EMAIL_HOST_USER = settings.EMAIL_HOST_USER print('about to email') from_email = EMAIL_HOST_USER to_email = [] to_email.append("[email protected]") subject = 'New Fabric - Standalone Nexus 9k Leaf/s for ' email = EmailMessage(subject, body_to_sent, from_email, to_email) email.content_subtype = "html" email.send()
Error:
about to email 13:59:56 [Q] ERROR Failed [spring-nineteen-muppet-artist] - 'NoneType' object is not callable : Traceback (most recent call last): File "/home/sgang31/.venvs3/netadc3/lib64/python3.6/site-packages/django_q/cluster.py", line 432, in worker res = f(*task["args"], **task["kwargs"]) TypeError: 'NoneType' object is not callable
you can try use string as parameter in function from django_q.tasks import async_task or from django_q.tasks import schedule using.
for example:
# server.abc.test.py
def _send_msg_task(msg: str):
pass
def async_send_msg(msg='hello world'):
task_id = async_task('server.acb.test._send_msg_task', msg)
return task_id