Skip to content

Need method to remove item from pool #670

@MidnightLady

Description

@MidnightLady

Technically, connection or channel pool can reconnect itself.
However, sometime channel can be closed for several issues.

async with channel_pool.acquire() as channel:
      queue = await channel.declare_queue('queue_name', arguments={**kwargs}, passive=True)

If queue doesn't exist or precondition failed, channel will be closed as a result. We can't use this channel and pool can't reconnect too.

The pool still keep this item, we can overwrite put method :

class ChannelPool(Pool):
    def put(self, item):
        if hasattr(item, 'is_closed') and item.is_closed:
            return
        super().put(item)

The problem is there is no way to remove in __item_set and __created variable. Name mangling can be work but not recommend.
Since __created = max_size, it won't create new item anymore.

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