Queues: ten tasks and go to sleep|INEMA.CLUB-PRO

Lesson 1 · 12 min

From chat to queue: why save tasks

In chat, the agent does one thing at a time and only while the window is open. A durable queue stores each request, runs one at a time, resumes after a crash, and separates what worked from what failed.

Start lesson
A row of paper cards arranged in sequence on a dark table, with one card highlighted.

In this lesson, you’ll

  1. 1The limit of chat: you have to keep watching
  2. 2The four guarantees of a durable queue
  3. 3Task states, from request to result
  4. 4Where inemaccbot fits in step 3

Goal: explain the four guarantees of a durable queue and why they let you step away.

01Chat × queue

The same request, in two different places.

Scroll down: each step below lights up its part of the diagram.

  1. 1/5

    Chat

    In chat, you type, wait, copy, and paste. If you close the window or the computer shuts down, the work in progress disappears. Ten tasks = ten waits with you in front.

  2. 2/5

    Durable queue

    The request is saved before it runs. In inemaccbot, the queue is a SQLite database on disk; in the homemade queue, it’s one file per task in a folder. Shut down? The task is still there.

  3. 3/5

    Worker

    A worker picks up a task, hands it to the agent, and waits. If the process crashes midway, on the next startup it recovers what was in flight before accepting new work.

  4. 4/5

    Result

    Each task ends in a clear state: it worked (with the file or text) or it failed (with the reason). That’s what you check in the morning.

  5. 5/5

    Why this lets you step away

    Save before running, one at a time, resume after a crash, and separate done from failed: with these four guarantees, turning off the screen doesn’t cost you work.

In inemaccbot, the request comes through Telegram; in the homemade queue from lesson 3, it’s an .md file in a folder. The idea is the same.

02The four guarantees

What you should expect from any queue, homemade or otherwise.

1. Save before running

The request becomes a record on disk as soon as it arrives. It doesn’t depend on an open window or the program’s memory.

In inemaccbot, each request becomes a job in a database table. It has a number (j13), a queue, a status, and a number of attempts remaining.

What this looks like day to dayYou send the request from your phone, the computer restarts, and the request is still in the list.

03Task states

The names change from one queue to another; the idea is the same.

Homemade queue (folders)
fila/
  entrada/   # requests waiting their turn
  rodando/   # the task the agent is working on now
  feito/     # request + response
  falhou/    # request + ERRO and the reason
inemaccbot (job status in the database)
queued    # in the queue, waiting its turn
running   # a worker picked it up and is running it
done      # finished with a result
failed    # ran out of attempts, with the reason
canceled  # you canceled it (/cancelar)
Repository example
  • Homemade queue: when you run it again, anything in rodando/ goes back to entrada/.
  • inemaccbot: the worker renews a task “lease” while it works. If the lease expires because the process crashed, the task goes back to queued as long as attempts remain.

04Step 3 in video

inemaccbot's durable queue and approval gate, in a minute and a half.

Ten tasks and go to sleep · 1 min 33 sVideo page with script →

05Test what you learned

The explanation appears after your answer.

Question 1 of 3

What's the essential difference between asking in chat and sending something to a durable queue?skill

To learn more

Next lesson