Skip to content
Discussion options

You must be logged in to vote

The context manager is the part that deletes the subscription.

Subscription.__aexit__() always calls delete(). In this example, cancelling sub_task unwinds async with subscription:. Because the transport is already down, delete() logs "local cleanup only", but its finally block still marks the object as deleted and closes the iterator. restore() cannot bring that object back after _deleted has been set.

I would keep ownership of the subscription outside the consumer task:

async def consume(sub):
    async for event in sub:
        match event:
            case DataChangeEvent(node=node, value=value):
                _logger.info("data change %r %s", node, value)
            case StatusCha…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@iamthebull
Comment options

Answer selected by iamthebull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants