Skip to content

fix(pubchem): add threading.Lock to cache and rate limiter#391

Merged
robotlearning123 merged 1 commit intomainfrom
fix/pubchem-safety-v2
Mar 29, 2026
Merged

fix(pubchem): add threading.Lock to cache and rate limiter#391
robotlearning123 merged 1 commit intomainfrom
fix/pubchem-safety-v2

Conversation

@robotlearning123
Copy link
Copy Markdown
Member

Summary

  • Add threading.Lock protecting _CACHE, _cache_put, and _rate_limit
  • Prevents data races in concurrent PubChem enrichment calls

Replaces #379

Test plan

  • tests/test_pubchem_safety.py verifies lock exists and concurrent cache writes succeed

elapsed = now - _last_request_time
if elapsed < _MIN_INTERVAL:
time.sleep(_MIN_INTERVAL - elapsed)
_last_request_time = time.monotonic()
@robotlearning123 robotlearning123 enabled auto-merge (squash) March 29, 2026 04:43
The module-level _CACHE dict and _last_request_time float were
unprotected. Add a threading.Lock to prevent data races in
concurrent enrichment calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the ci-verified All required CI checks have passed label Mar 29, 2026
@robotlearning123 robotlearning123 merged commit a5f9886 into main Mar 29, 2026
22 checks passed
@robotlearning123 robotlearning123 deleted the fix/pubchem-safety-v2 branch March 29, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-verified All required CI checks have passed python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants