fix: offload refresh() blocking I/O to a thread; document MissingApplicationID (v0.1.2)

refresh() did folder scan, magic-byte sniff, and per-file image reads directly
on the event loop. Offload via asyncio.to_thread so the loop stays responsive
during a large sync; behavior (validation, size cap, stem-collision and
missing-dir raises) is unchanged.

Also documents discord.MissingApplicationID in refresh()'s Raises contract -
it is a ClientException, not an HTTPException, so it was previously uncaught
by the existing except clauses and unlisted in the docstring.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-03 16:17:59 -04:00
parent d59bdcc9b9
commit 6fc4e14f3c
4 changed files with 32 additions and 9 deletions
+10 -1
View File
@@ -8,7 +8,7 @@ source of truth: a file removed means its emoji is deleted.
## Install
```
dpy_appemojis @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_appemojis.git@v0.1.0
dpy_appemojis @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_appemojis.git@v0.1.2
```
## Usage
@@ -79,10 +79,19 @@ swallowed:
- exceeding the 2000 cap raises `DPYAppEmojisError` **before** any create
- a discord API error (`HTTPException`, which covers `Forbidden`) propagates **unwrapped** so
a partial sync never hides behind a silent success
- `MissingApplicationID` (raised if `refresh()` runs before the client's `application_id` is
set, e.g. before `on_ready`) also propagates **unwrapped** — it is a `ClientException`, not
an `HTTPException`, so it is never caught by an `except discord.HTTPException` clause
`emoji(name)` / `get.<name>` for a name that wasn't synced raise `KeyError` / `AttributeError`
(call `refresh()` first).
## Async stance
`refresh()` offloads its blocking filesystem work (folder scan, magic-byte sniff, per-file
image read) to a worker thread via `asyncio.to_thread`, so the event loop stays responsive
during a large sync. Only the discord API calls run on the loop directly.
## Versioning
Tagged `vX.Y.Z`; pin a tag in your install line. Targets `discord.py>=2.5` (not