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
Cross platform file caching #44
Comments
Michael Bayer (zzzeek) wrote: I'm confused. The file backend already uses an RW lock, note:
as far as how to make it cross platform, I've no idea how a read/write file lock would be implemented on windows (I know how to do it with threading.condition, if you want an option to be present that works in only one process). |
Antoine Bertin (diaoul) wrote: What about something using pywin32 or portalocker? I know it has a rw lock but AFAIK it is not optional. |
Michael Bayer (zzzeek) wrote: right, was going to say earlier, dependencies on win32 type stuff I can't specifically have directly in dogpile.cache, so I'm open to having the FileLock factory be pluggable, e.g. as an argument to DBMBackend. feel free to send a pullreq. |
Antoine Bertin (diaoul) wrote: Then don't depend on it, just have a Windows specific FileLocker and use it if os.platform == 'nt' What do you think about that? |
Michael Bayer (zzzeek) wrote: we already have lock mechanisms as pluggable. I'd rather not endorse a particular win32 system as I don't have the resources to test or support it, portalocker hasn't had a commit in 3 years (does it work at scale? does it work on the latest windows? etc., I have no idea). I commonly create hooks so that features I can't support can be implemented and maintained by others on the outside. |
Antoine Bertin (diaoul) wrote: Well, I don't have the resources either so I hope a contributor will step up. |
Jeroen () wrote: I'm running subliminal and made some changes to overcome the problems in windows. I do not know if it solves all the problems or if it even works, but it fixed my errors :D
PS This is my first time installing/editing python, entering a possible bugfix. sorry for the inconvenience of not testing it and not providing a .patch. |
Michael Bayer (zzzeek) wrote: take a look at 34af3b7 - you can take your FileLock approach and subclass AbstractFileLock with it, and drop the lock in. An example of usage is provided. I didn't actually test dropping in an alternate lock implemenation, so if there's any problems with my checkin, reopen |
Changes by Michael Bayer (zzzeek):
|
Antoine Bertin (diaoul) wrote: I don't understand why it doesn't bother you to depend on fnctl but it does bother you to depend on some win32 stuff. Anyway, thanks for implementing a clean workaround :) Do you plan on releasing soon? |
Michael Bayer (zzzeek) wrote: if there were a windows-compatible file locking system in the Python std lib, I'd use that, but there's not, which IMO says a lot about the feasibility of locking files on windows. portalocker is at version 0.3, says it's "beta", and hasn't had a commit in three years. It apparently has one ticket just opened two days ago that the dev has responded to, so that's good, but it seems to be a very basic issue. So i really have very little indication that portalocker is a widely used and accepted system that I can confidently import in my library knowing that it's the best possible approach. On windows, you probably get much better performance using threading conditions, which is why I also offer that as an option. Windows just doesn't have a single, widely accepted approach for this kind of thing and I have no interest in endorsing one of them. |
Antoine Bertin (diaoul) wrote: Thanks for the clarification. |
Antoine Bertin (diaoul) wrote: I can't test but the fact that there's still "import fcntl" will still throw "ImportError: No module named fcntl" under windows. |
Michael Bayer (zzzeek) wrote: good idea |
Michael Bayer (zzzeek) wrote: also why can't you test? would be a much better idea if you could before any release happens |
morpheus65535 (morpheus65535) wrote: This error message seems to be back in version 0.6.4. Could it still be fixed? Thanks! |
Hi, |
I've just re-read this issue and it seems to indicate that everything works on windows. as described in #44 (comment) and in the docs at https://dogpilecache.sqlalchemy.org/en/latest/api.html#dogpile.cache.backends.file.DBMBackend you would use your win32 locking library of choice and plug it in using the lock_factory parameter. |
I agree, but I would suggest to mention it in the documentation (or at least in the opening example) - it will save the time to figure it out from the error message. Just my 10cents.... |
Migrated issue, originally created by Anonymous
I'm looking for a cross platform file caching backend as the dogpile.cache.backends.file requires fcntl which is Unix.
In my case I'll have a single thread doing rw operations so I don't mind not having a rw lock.
The text was updated successfully, but these errors were encountered: