Skip to content

Commit

Permalink
Merge pull request #20 from reallistic/bugfix/remove_debug_logging
Browse files Browse the repository at this point in the history
removing debug logging messages since they can cause race conditions
  • Loading branch information
reallistic committed Apr 26, 2021
2 parents e646f30 + f4b53cd commit 346f3d3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pyloot/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def get_object_descriptors(
"""
Return list of ::class::`ObjectDescriptor` instances for all objects in memory
after a call to gc.collect.
WARNING: Logging in this thread can cause a race condition if gevent is enabled
"""

if ignored:
Expand All @@ -139,26 +141,20 @@ def get_object_descriptors(

del ignored

logger.debug("Collecting gc")
gc.collect()

logger.debug("retrieving gc objects")
objs: List[object] = gc.get_objects()

logger.debug("filtering gc objects")
objs = [obj for obj in objs if _should_include_object(obj, ignore_set)]
logger.debug("getting data for each obj gc objects")
results = [get_data(obj) for obj in objs]
del objs
del ignore_set
child_to_parent: Dict[int, Set[int]] = defaultdict(set)

logger.debug("building child_to_parent map")
for descr in results:
for child_id in descr.child_ids:
child_to_parent[child_id].add(descr.id)

logger.debug("building parent_ids")
for descr in results:
if descr.id in child_to_parent:
descr.parent_ids.extend(child_to_parent[descr.id])
Expand Down

0 comments on commit 346f3d3

Please sign in to comment.