Open pedrovgp opened 4 years ago
Usually this means that somewhere there is a string evaluated that is not correct python. Are you calling a valid management command? And are you sure the error is not happening there?
I found the problem. args should be a tuple. It must be unpacked somewhere in the code. Changing to
Schedule.objects.get_or_create(
name='send_csat_survey_emails_temp',
defaults=dict(
func='django.core.management.call_command',
args=("send_csat_survey_emails",),
...
)
)
did it.
The docs here show the Schedule class being instatiated with args="2,-2". I guess that was the origin of my confusion. For sanity sake, I tried args="send_csat_survey_emails, ",
but that did not work either.
I don't know if you want to keep the issue open (you may want to update docs or so), but feel free to close it. I am using Python 3.8 and Django 2.2 by the way.
I think it has more to do with how call_command handles parameters .That particular example in the docs works well. I'll dig into it a bit to see what I can find.
Can confirm that this happens when anything that's not a tuple is specified in args. The function name does not matter; in fact, it doesn't even has to be a valid function.
Similar error for kwargs - if anything but a dictionary is specified, an error is raised:
13:33:38 [Q] ERROR name 'asdf' is not defined
This is very easy to mess up since you can define schedules in the admin, and the help text does not even specify the correct format for these fields.
we call check the field 'args' in table django_q_schedule , it must be like ('sync_file',)
I have created a Schedule through the shell, like this:
It was successfully created.
But no task is queued and qcluster logs: [Q] ERROR malformed node or string: <_ast.Name object at 0x7fba399cc278>
I have tried changing the name of the Schedule, but I got the same error.
Am I doing something wrong?