You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writing a processor function that returns a plain string
asyncdefprocess(job):
return'foo'
and listening to the queue events in JavaScript will throw an error when JavaScript tries to JSON.parse the return value:
SyntaxError: Unexpected token 'o', "foo" is not valid JSON
at JSON.parse (<anonymous>)
at QueueEvents.consumeEvents (/Users/clemens/Projects/bullmq-example/producer/node_modules/bullmq/dist/cjs/classes/queue-events.js:92:53)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async QueueEvents.run (/Users/clemens/Projects/bullmq-example/producer/node_modules/bullmq/dist/cjs/classes/queue-events.js:60:17)
Similarily, returning an array will also fail
asyncdefprocess(job):
return ['foo']
Error processing job Invalid input of type: 'list'. Convert to a bytes, string, int or float first.
I think the python code should probably use json.dumps(result) here
frombullmqimportWorkerasyncdefprocess(job):
return'foo'asyncdefmain():
# Feel free to remove the connection parameter, if your redis runs on localhostworker=Worker("myQueue", process, {"connection": "localhost"})
# This while loop is just for the sake of this example# you won't need it in practice.whileTrue: # Add some breaking conditions hereawaitasyncio.sleep(1)
# When no need to process more jobs we should close the workerawaitworker.close()
if__name__=="__main__":
asyncio.run(main())
SyntaxError: Unexpected token 'o', "foo" is not valid JSON
at JSON.parse (<anonymous>)
at QueueEvents.consumeEvents (/Users/clemens/Projects/bullmq-example/producer/node_modules/bullmq/dist/cjs/classes/queue-events.js:92:53)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async QueueEvents.run (/Users/clemens/Projects/bullmq-example/producer/node_modules/bullmq/dist/cjs/classes/queue-events.js:60:17)
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Version
1.13.2
Platform
Python
What happened?
Writing a processor function that returns a plain string
and listening to the queue events in JavaScript will throw an error when JavaScript tries to JSON.parse the return value:
Similarily, returning an array will also fail
I think the python code should probably use
json.dumps(result)
herebullmq/python/bullmq/worker.py
Line 167 in 3b67193
How to reproduce.
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: