Skip to content

Closing stream connection #311

@alienbrett

Description

@alienbrett

I'm writing an application that runs a stream client before stopping it later, and I was frustrated with the stream client lifecycle.

If you're having problems with tasks being cancelled on event loop closure with Asyncio, try the following line after unsubscribing (or just after you stop handling stream messages):

if stream_client._socket is not None:
    await stream_client._socket.close()

I spent hours trying to figure out where my async flow was failing, and I realized far too late that it was due to bad socket handling with this library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions