Sitelet https://github.com/Stephenson-Software/trace-client-python/issues/5
Skip to content

Sender thread in _drain has no outer guard around _send #5

Description

@dmccoystephenson

TraceClient._drain (trace_client/trace_client.py:174-181) calls self._send(body) with no surrounding try. Only the try blocks inside _send keep the sender thread alive.

On main, _send builds the urllib.request.Request outside its try, so a base URL with no scheme kills the thread (#3). PR #4 moves that construction inside the try. After that change, no statement known to raise is left outside a guard. The thread's survival still depends on every future edit to _send keeping all raising code inside that try, though. If one slips through, the thread dies and a traceback goes to the host program's stderr. After that, report() keeps filling the queue up to QUEUE_CAPACITY with nothing draining it.

Suggested hardening (defense in depth, no behavior change today): wrap the self._send(body) call in _drain in try / except Exception: # noqa: BLE001. The handler logs _LOG.debug("[trace] ...") and continues the loop. A regression test can patch _send to raise once. It then asserts that threading.excepthook is not called and that a later report is still delivered.

No Java-visible behavior would change.

Depends on / follows #4.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions