Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new SQLiteBucket subclass that uses py-filelock #68

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

JWCook
Copy link
Contributor

@JWCook JWCook commented Apr 5, 2022

Fixes #67 and #60

The changes in #61 made SQLiteBucket safe to use with multiple threads, and multiple processes with a shared Limiter.

However, to work with multiple processes without a shared Limiter, a different means of inter-process communication is needed. A file lock seems to be the best way to do this. This does reduce performance, and also requires an extra dependency, so I'm making a separate bucket class for this.

Changes

  • Added FileLockSQLiteBucket
  • Added a test using multiple processes without a shared Limiter
  • Bumped LimitContextDecorator log messages down to debug, as it gets a bit spammy during the longer tests (with pytest -v -s)
  • Added backend dependencies as optional extras in poetry.dependencies and poetry.extras
    • This does not cause these these dependencies to be installed by default, but adds them to package metadata
    • Also makes them installable via poetry install -E all or pip install pyrate-limiter[all]

@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #68 (49392ad) into master (eda4d07) will increase coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #68      +/-   ##
==========================================
+ Coverage   97.95%   98.06%   +0.11%     
==========================================
  Files           8        8              
  Lines         342      362      +20     
  Branches       32       32              
==========================================
+ Hits          335      355      +20     
  Misses          4        4              
  Partials        3        3              
Impacted Files Coverage Δ
pyrate_limiter/limit_context_decorator.py 100.00% <100.00%> (ø)
pyrate_limiter/sqlite_bucket.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eda4d07...49392ad. Read the comment docs.

@JWCook JWCook force-pushed the filelock branch 3 times, most recently from c497983 to 7b06708 Compare April 6, 2022 19:23
@JWCook JWCook marked this pull request as ready for review April 6, 2022 19:28
@JWCook JWCook mentioned this pull request Apr 6, 2022
@JWCook JWCook changed the title Add optional filelock for SQLiteBucket Add a new SQLiteBucket subclass that uses py-filelock Apr 6, 2022
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.

SQLite locks
2 participants