Skip to content

stale_while_revalidate pool size and shutdown #978

@glensc

Description

@glensc

So, I read up about stale_while_revalidate

# https://requests-cache.readthedocs.io/en/stable/user_guide/expiration.html#asynchronous-revalidation
stale_while_revalidate=True,

And at some point got pool size warnings:

WARNING  Connection pool is full, discarding connection: 192-168-x-y.[redacted].plex.direct. Connection pool size: 10  
WARNING  Connection pool is full, discarding connection: 192-168-x-y.[redacted].plex.direct. Connection pool size: 10  
WARNING  Connection pool is full, discarding connection: 192-168-x-y.[redacted].plex.direct. Connection pool size: 10

so, I dug up some code:

  • def _resend_async(self, *args, **kwargs):
    """Send a non-blocking request to refresh a cached response"""
    logger.debug('Using stale response while revalidating')
    thread = Thread(target=self._send_and_cache, args=args, kwargs=kwargs)
    thread.start()

and that code immediately raised me questions:

  1. there's no control of how many threads can be created
  2. there's no method to wait for the background threads to be finished

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions