Skip to content

Fix the dashboard hang; make send pacing configurable; Gmail quota retries; logo beside the sign-off - #245

Open
PandasProperty wants to merge 6 commits into
ethanplusai:mainfrom
PandasProperty:fix/shared-db-connection-and-send-pacing
Open

PandasProperty wants to merge 6 commits into
ethanplusai:mainfrom
PandasProperty:fix/shared-db-connection-and-send-pacing

Conversation

@PandasProperty

@PandasProperty PandasProperty commented Nov 12, 2026 •

Copy link
Copy Markdown

Four changes from running Sellbird day to day on a fresh Gmail mailbox under a warmup ramp. Each is its own commit.

Fixed: the dashboard hangs under its own requests

Every API call opened and closed its own aiosqlite connection on its own thread. Under that churn the dashboard process could lock up for good inside SQLite's unix VFS: a sample of the hung process showed 19 threads waiting on the VFS mutex (16 in unixOpen, 2 in unixClose) with no holder, and the browser showed every request pending until the process was killed. A write-lock probe over a full heartbeat cycle ruled out the heartbeat holding the database.

The dashboard and the heartbeat now keep one connection per database for the life of the process (storage.share_connections), handed to one user at a time, reentrant for the task that holds it, rolled back and row_factory-reset on the way out. One-shot commands and tests open connections as before. Worker threads are daemons and connections are stopped when their event loop is collected, so short commands and test runs exit cleanly. New tests in tests/test_storage.py; the full suite also passes with sharing forced on, about 30% faster.

Changed: channels.email.max_sends_per_cycle

The sender drained up to 8 approved emails a cycle a few seconds apart, so at 5 a day under the ramp the whole day's cold email left in one minute. The new setting (default 8, unchanged) sets how many each inbox sends per heartbeat; 1 sends one per cycle. The due-email page is now at least the default size, so a few gate-blocked emails at the front of the queue can't use up a small cycle. Tests in tests/test_sends_per_cycle.py.

Fixed: Gmail quota answers and timed-out reads fail the reply read

A busy inbox's first full read can hit Gmail's per-user-per-minute quota; the 403/429 failed the read, which held every send that cycle. Those answers are now retried with backoff (about a minute in all, honouring Retry-After) before failing. The same goes for a read whose connection times out or drops (httpx.HTTPError): reading a week of a busy inbox is one call per message, and one slow call out of several hundred failed the whole read every cycle, holding sends all day; it did nothing on Gmail's side, so it is now repeated with the same backoff. A send is still never repeated, since it may have gone out. The log line names the exception type (str() of a timeout is often empty). Tests in tests/test_gmail_rate_limit.py.

Changed: the logo sits beside the sign-off

With signature.logo set, the logo sits next to the sign-off lines (the first name the writer now signs every cold email with, or a closing paragraph opening with persona.name when operator email rules write their own), persona.company in them opening signature.link, and the cold-email compliance footer follows in smaller grey type instead of the logo hanging under the footer. The merge with main drops the sign-off rule this branch had added to the writer prompt, since the writer signs itself now. A mail-tester run of the rendered email through the Gmail pipeline scored 8.9/10, with the only deductions being the usual image-in-a-short-email rules.

Test plan

  • pytest after merging main: 3720 passed, 27 skipped
  • Same with sharing forced on for every test
  • Dashboard and heartbeat run for a day with the shared connection; the hang did not recur under the request pattern that triggered it (confirming two signals at once)
  • Live: emails left one per cycle at max_sends_per_cycle: 1

🤖 Generated with Claude Code

PandasProperty and others added 6 commits November 12, 2026 16:57
With channels.email.signature.logo set, an email that ends with
persona.name on its own line now gets the logo next to the sign-off
lines, with persona.company in them opening signature.link. On cold
email the compliance footer (postal address and opt-out line) follows in
smaller grey type instead of the logo hanging under the footer. The
writer prompt asks for that two-line sign-off so every email qualifies.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
A busy inbox's first full read can hit Gmail's per-user-per-minute
quota; the 403 or 429 failed the read, which held every send that
cycle. Such answers are now retried with backoff (about a minute in
all, honouring Retry-After) before failing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
The sender drained up to 8 approved emails a cycle a few seconds apart,
which at 5 a day under a warmup ramp meant the whole day's cold email
left in one minute. channels.email.max_sends_per_cycle (default 8,
unchanged) sets it; 1 sends one email per heartbeat cycle. The sender
always looks through at least the default page of due emails, so a few
gate-blocked ones at the front of the queue can't use up a small cycle.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
Every API call opened and closed its own aiosqlite connection on its own
thread, and under that churn the dashboard process could lock up inside
SQLite's unix VFS for good: every request pending in the browser until
the process was killed. The dashboard and the heartbeat now keep one
connection per database for the life of the process
(storage.share_connections), handed out to one user at a time, reentrant
for the task that holds it, rolled back and reset on the way out. One-shot
commands and tests open connections as before. Worker threads are daemons
and connections are stopped when their loop is collected, so test runs
and short commands exit cleanly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
Upstream's writer now signs every cold email itself with the sender's
first name and rewrote prompts/writer.md, so the sign-off rule this
branch added to the prompt is dropped. The signature renderer takes that
one-line first name as the sign-off too (a closing paragraph opening
with persona.name still counts, for operator email rules that write
their own), with a test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
Reading a busy inbox is one call per message. A read that timed out or
dropped its connection on any one of them failed the whole read, and a
failed read holds every send that cycle; on an inbox of several hundred
messages a week, one such call per cycle held sends all day. A read did
nothing on Gmail's side, so it is now repeated with the same backoff as
a quota answer. A send is still never repeated, since it may have gone
out. The log line names the exception type, since str() of a timeout is
often empty.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: PandasProperty <anda.nenu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant