This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.3.

# Resource Management - `kombu.resource`

Generic resource pool implementation.

class kombu.resource.Resource(limit=None, preload=None, close_after_fork=None)

  Pool of resources.

  exception LimitExceeded

    Limit exceeded.

  acquire(block=False, timeout=None)

    Acquire resource.

    ## Arguments:

    > block (bool): If the limit is exceeded,

    >   then block until there is an available item.

    > timeout (float): Timeout to wait

    >   if `block` is true. Default is `None` (forever).

    raises LimitExceeded:

      if block is false and the limit has been exceeded.:

  close_after_fork = False
  close_resource(resource)
  collect_resource(resource)
  force_close_all(close_pool=True)

    Close and remove all resources in the pool (also those in use).

    Used to close resources from parent processes after fork (e.g. sockets/connections).

    ## Arguments:

    > close_pool (bool): If True (default) then the pool is marked

    >   as closed. In case of False the pool can be reused.

  property limit
  prepare(resource)
  release(resource)
  release_resource(resource)
  replace(resource)

    Replace existing resource with a new instance.

    This can be used in case of defective resources.

  resize(limit, force=False, ignore_errors=False, reset=False)
  setup()