Skip to main content

Facilities for shared access to files.

Function lockfile(path, ext=None, poll_interval=None, timeout=None)

A context manager which takes and holds a lock file.

Parameters:

  • path: the base associated with the lock file.
  • ext: the extension to the base used to construct the lock file name. Default: ".lock"
  • timeout: maximum time to wait before failing, default None (wait forever).
  • poll_interval: polling frequency when timeout is not 0.

Class SharedAppendFile

A base class to share a modifiable file between multiple users.

The use case was driven from the shared CSV files used by cs.nodedb.csvdb.Backend_CSVFile, where multiple users can read from a common CSV file, and coordinate updates with a lock file.

This presents the following interfaces:

  • __iter__: yields data chunks from the underlying file up to EOF; it blocks no more than reading from the file does. Note that multiple iterators share the same read pointer.

  • open: a context manager returning a writable file for writing updates to the file; it blocks reads from this instance (though not, of course, by other users of the file) and arranges that users of __iter__ do not receive their own written data, thus arranging that __iter__ returns only foreign file updates.

Subclasses would normally override __iter__ to parse the received data into their natural records.

Class SharedAppendLines

MRO: SharedAppendFile
A line oriented subclass of SharedAppendFile.

Class SharedCSVFile

MRO: SharedAppendLines, SharedAppendFile
Shared access to a CSV file in UTF-8 encoding.

Release files for cs.sharedfile 20190102

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs.sharedfile 20190102
File Size Uploaded
cs.sharedfile-20190102.tar.gz 5.5 kB Details

Release files / cs.sharedfile-20190102.tar.gz

Download URL cs.sharedfile-20190102.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cbb2d511926590b3f5720b78b8111b593ec202d6618137de249c6c6642a54ec8
BLAKE2b-256 checksum
How to use checksums
9cfdd37ded690977e715b123b0ae5b791f935fff9ec59f49e68d17fa347592e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.0 CPython/3.6.6

Release history Release notifications | RSS feed

This release

20190102 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page