Skip to content

BLE: close() can self-join the event-loop thread on disconnect #968

Description

@lalonggone

On an unsolicited disconnect, bleak calls the disconnect callback (set to self.close()) on its own event-loop thread. close() then calls self._eventThread.join(...), i.e. joining the current thread, which raises RuntimeError: cannot join current thread, so cleanup doesn't finish (self.client is left set and _disconnected() never runs).

Pre-existing and separate from the hang fix in #967. A fix probably needs close()/disconnect() to notice when they're running on the event-loop thread and avoid joining/blocking it.

Seen on Linux, Python 3.14, bleak 2.1.1, RAK4631 (platform-independent).

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