Skip to content

v0.4.9 -- bunpy.queue

Choose a tag to compare

@tamnd tamnd released this 27 Apr 17:52
· 99 commits to main since this release
v0.4.9
4a7be65

In-process background job queue via import bunpy.queue as queue. Pure Go, no new deps.

import bunpy.queue as queue

q = queue.new(workers=4)

@q.handler("send_email")
def handle_email(job):
    send(job["data"]["to"], job["data"]["subject"])

q.enqueue("send_email", {"to": "x@x.com", "subject": "Hi"})
q.wait()
q.stop()

# or as context manager
with queue.new(workers=2) as q:
    q.handler("ping")(lambda job: print("ping"))
    q.enqueue("ping", {})

Jobs carry id, type, data, and attempt. Handler errors drop the job
but do not crash the worker pool.