-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Modifications to SqliteStorage to allow for custom filepaths #77
Conversation
aw_datastore/storages/sqlite.py
Outdated
if (self.last_commit - datetime.now()) > timedelta(seconds=10): | ||
if self.enable_lazy_commit: | ||
self.num_uncommited_statements += num_statements | ||
if self.num_uncommited_statements > 10: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why lower it from 50 to 10?
And why do you need the enable_lazy_commit at all? It should work transparently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the 50 to 10 was accidental. Fixed.
enable_lazy_commit=True
effectively makes the code asynchronous, which wasn't acceptable for a use-case I had (sync).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood that the use-case was sync, but why do you really need it?
Why do you need the absolute latest event? If you actually do, can't you instead force a commit when you actually need it like when using the REST API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need the absolute latest event?
Because I'm checking for the latest sent event sometimes, to know which events to send (I'd need to know about eventual uncommitted events).
If you actually do, can't you instead force a commit when you actually need it like when using the REST API?
I am calling it through the ServerAPI
class in aw_server/api.py
, and there doesn't seem to be any commit done through the REST API? How would you force a commit through the REST API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ActivityWatch/aw-server/blob/master/aw_server/api.py#L53
https://github.com/ActivityWatch/aw-core/blob/master/aw_datastore/storages/sqlite.py#L224
If that's the case you should already be getting the latest event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's weird, because I definitely didn't (That's why I did this in the first place). I'll take a closer look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's because you are running it as a seperate process?
Same thing here as with aw-server-rust, you should not be accessing a SQLite database from multiple threads or processes. This can corrupt the database if not configured properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's because you are running it as a seperate process?
I'm not, I'm instantiating two ServerAPI
objects with two different SqliteDatastore
objects (with different db paths) in the same process and thread.
I've reproduced the issue by setting enable_lazy_commit=True
, not sure what is going wrong, only seems to happen if process dies shortly after commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure it out, I'm going ahead and merging this anyway.
Codecov Report
@@ Coverage Diff @@
## master #77 +/- ##
==========================================
+ Coverage 94.97% 95.11% +0.14%
==========================================
Files 33 33
Lines 1551 1598 +47
Branches 233 293 +60
==========================================
+ Hits 1473 1520 +47
- Misses 46 47 +1
+ Partials 32 31 -1
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #77 +/- ##
==========================================
+ Coverage 94.97% 95.11% +0.14%
==========================================
Files 33 33
Lines 1551 1598 +47
Branches 233 293 +60
==========================================
+ Hits 1473 1520 +47
- Misses 46 47 +1
+ Partials 32 31 -1
Continue to review full report at Codecov.
|
I needed this in ActivityWatch/aw-server#50