Skip to content

the "distributed.worker" logger gains ~thousand DequeHandler instances during a pytest run #5973

@graingert

Description

@graingert

running len(logging.getLogger("distributed.worker").handlers) shows a few thousand DequeHandler instances in there.
This means that logging messages from the worker or adding handlers to the worker gradually gets slower and slower as the test suite progresses.

the handlers are supposed to be cleared when the worker is GC'd by

weakref.finalize(self, logger.removeHandler, self._deque_handler)
however
@functools.lru_cache(None)
def _iscoroutinefunction_cached(f):
return _iscoroutinefunction(f)
def iscoroutinefunction(f):
# Attempt to use lru_cache version and fall back to non-cached version if needed
try:
return _iscoroutinefunction_cached(f)
except TypeError: # unhashable type
return _iscoroutinefunction(f)
keeps a permanent strong reference to the worker:

image

see #4481 and #4469

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions