Skip to content

emrg: tighten bare excepts in _send_shutdown and _stop_daemon - #16

Merged
argszero merged 2 commits into
masterfrom
fix/tighten-main-excepts
Jul 18, 2026
Merged

emrg: tighten bare excepts in _send_shutdown and _stop_daemon#16
argszero merged 2 commits into
masterfrom
fix/tighten-main-excepts

Conversation

@argszero

Copy link
Copy Markdown
Owner

Changes

Two remaining bare except Exception in emrg/__main__.py narrowed to specific types:

_send_shutdown (line 139)

except Exception → except (OSError, asyncio.TimeoutError, json.JSONDecodeError, UnicodeDecodeError)

Wraps: writer.write/drain (OSError), asyncio.wait_for(reader.readline) (TimeoutError, OSError), json.loads(line.decode()) (JSONDecodeError, UnicodeDecodeError).

_stop_daemon (line 176)

Same exception types. Wraps: asyncio.run(_get_pid()) (same I/O + JSON errors from the inner connect/write/read/decode), os.kill (OSError), cleanup_server (OSError).

Verification

  • ✅ 80 tests passing
  • ✅ Import + CLI check OK
  • ✅ AST parse OK

- _send_shutdown: except Exception → (OSError, asyncio.TimeoutError, json.JSONDecodeError, UnicodeDecodeError)
- _stop_daemon: except Exception → same

Both wrap I/O on the daemon connection (OSError + TimeoutError)
plus JSON decoding of the response (JSONDecodeError + UnicodeDecodeError).

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #15

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #16

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #17

@argszero
argszero merged commit f03878f into master Jul 18, 2026
@argszero
argszero deleted the fix/tighten-main-excepts branch July 28, 2026 12:00
argszero added a commit that referenced this pull request Aug 9, 2026
…T13:16:36) (#596)

Carries the emergency Windows v0.2.15 regression hotfix (host observed
cmd-window storm + daemon startup failure, had to reboot):
- #592: CREATE_NO_WINDOW across all 34 subprocess sites (emrg/_win.py
  win32_no_window_kwargs) + GUI spawn throttle + scheduler connect backoff
- #593: daemon port-file self-heal (_port_keepalive_loop) + G43 PID guard
  (never delete a live daemon's port file)
- #594: TUI spawn throttle (_MAX_SPAWN_ATTEMPTS=3 + reset on connect)
- #595: evolution_prompt quick-ref entries

Per host authorization (rant #16/#18: release without waiting for
real-machine verification), this bump goes straight to Build Release on
merge.
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