Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 signup: the person chooses the password and name on the confirm page 83c7aa6 2 weeks, 5 days ago History
queue.py · 1.8 KB · 41 lines
1"""queue -- the daemon's deferred-work queue.
2
3object_daemon.process_queue reads `msg_*` keys out of THIS object's state
4on every poll and executes the target object each message names. The queue
5primitive already supports everything deferred work normally needs:
6
7 visible_after run no earlier than this epoch second (a DELAY)
8 priority_level higher goes first
9 expires_at drop it if it never became runnable in time
10 max_attempts retry with exponential backoff (2**attempts seconds),
11 then park the message as failed rather than looping
12 queue_name independent named queues
13
14Enqueue with object_daemon_control.enqueue_message() or POST
15/daemon/queue/messages. Status walks pending -> processing ->
16completed | failed | expired, and the message keeps its attempt count, so
17a dead job is inspectable instead of vanishing.
18
19Like the scheduler object this is inert on purpose -- the work is data in
20its state, and the contract lives in object_daemon.process_queue. Without
21this file the daemon simply reports "Queue: no queue object" and every
22enqueued message waits forever, which is why it ships in a package.
23
24What this queue is NOT: a worker pool. Messages execute inside the daemon's
25poll loop, so a job that takes thirty seconds delays that daemon's other
26passes by thirty seconds. That is fine for follow-on writes, notifications,
27recomputes and short fetches; heavy or long work (image processing, OCR,
28model calls) wants its own process and should say so plainly rather than
29quietly starving the aging pass.
30"""
31
32
33def GET(request):
34 return {"ok": True,
35 "note": "msg_* entries in this object's state drive "
36 "object_daemon.process_queue; enqueue via "
37 "/daemon/queue/messages"}
38
39
40def POST(request):
41 return {"ok": True}