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

fix: added conversation lock file management in LogManager #295

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Dec 1, 2024

Important

Adds optional directory locking to LogManager using fcntl to prevent concurrent access.

  • Locking Mechanism:
    • Adds optional locking to LogManager using fcntl in __init__.
    • Creates .lock file in log directory and acquires exclusive lock.
    • Raises RuntimeError if lock cannot be acquired.
  • Destructor:
    • Implements __del__ to release lock and close file descriptor.
    • Logs errors if lock release fails.

This description was created by Ellipsis for 48b62ca. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 48b62ca in 26 seconds

More details
  • Looked at 59 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_VdJV7VsGAc34lwoS


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -97,7 +117,15 @@ def __init__(
if _branch not in self._branches:
self._branches[_branch] = Log.read_jsonl(file)

# TODO: Check if logfile has contents, then maybe load, or should it overwrite?
def __del__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Using __del__ for releasing resources is not reliable. Consider using a context manager to ensure the lock is released properly.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 72.25%. Comparing base (88c715b) to head (48b62ca).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/logmanager.py 75.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
+ Coverage   72.24%   72.25%   +0.01%     
==========================================
  Files          64       64              
  Lines        4331     4351      +20     
==========================================
+ Hits         3129     3144      +15     
- Misses       1202     1207       +5     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 71.04% <75.00%> (+0.04%) ⬆️
openai/gpt-4o-mini 70.90% <75.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ErikBjare ErikBjare merged commit 7255f25 into master Dec 8, 2024
7 checks passed
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.

2 participants