HTTP 400 errors when using run_every in IronWorker Python
Say you have a small script like the following:
import sys
from iron_worker import IronWorker
from iron_worker import Task
worker = IronWorker()
task = Task(
code_name="HelloWorld",
scheduled=True,
run_every=sys.argv[1])
response = worker.queue(task)
print response
If you want to schedule the job to run every minute you could call python schedule.py 60
. This will unfortunately return an HTTP 400 response.
The reason is that the run_every
parameter is being passed as a string. A simple fix is to convert to an int
:
task = Task(
...
run_every=int(sys.argv[1]))