Skip to content

Conversation

@tjfulle
Copy link
Collaborator

@tjfulle tjfulle commented Oct 31, 2025

pickle test case lock files. it could be faster?

Copy link
Collaborator

@mdmosby mdmosby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where this is headed! Any measurements on impact to performance for pickle vs JSON?

generators: set[AbstractTestGenerator] = set()
for root, paths in self.roots.items():
found, e = config.pluginmanager.hook.canary_discover_generators(root=root, paths=paths)
print(found)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from development? Otherwise should it be logged?

Suggested change
print(found)

Comment on lines +30 to +47
delay = 0.5
attempt = 0
while attempt <= attempts:
# Guard against race condition when multiple batches are running at once
attempt += 1
try:
if protocol == JSON:
with open(file, "r") as fh:
return json.load(fh)
else:
with open(file, "rb") as fh:
return pickle.load(fh) # nosec B301
except Exception:
time.sleep(delay)
delay *= 2
raise FailedToLoadError(
f"Failed to load {file.name} after {attempts} {pluralize('attempt', attempts)}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this retry pattern is common. Should we establish a retry decorator in utils and use that throughout?

except json.JSONDecodeError:
logger.warning(f"Unable to load {file}!")
continue
state = serialize.load(file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implies that db might be a database of some sort that provides a (potentially locked/threadsafe) file handle. Should we consider passing the open method to serialize.load, or am I thinking too far ahead given that I don't think that behavior is currently implemented by db.open anyhow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants