py-filelock | A platform independent file lock for Python | Machine Learning library
kandi X-RAY | py-filelock Summary
kandi X-RAY | py-filelock Summary
A platform independent file lock for Python
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of py-filelock
py-filelock Key Features
py-filelock Examples and Code Snippets
Community Discussions
Trending Discussions on py-filelock
QUESTION
I have a service that load and dump data from a python dict
into a file using python 2.7 cPickle
. This service can be called simultaneously by many users.
What approach would allow cPickle
to read and dump data into a single file in a multithreading context in order to avoid problems of desynchronization (loading while another process is dumping) of the data during operations?
I was thinking of using filelock but I havent been successful yet.
With my code below, the file is always have cPickle.load(cache_file)IOError: [Errno 13] Permission denied"
error in init_cache()
or update_cache()
ANSWER
Answered 2017-Jul-06 at 12:35According to Filelock documentation you should wrap the lock.acquire inside the try{}except{}
. Otherwise it might just crash your app with unhandled exception when your acquire times out. See https://pypi.python.org/pypi/filelock
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install py-filelock
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page