Skip to main content

Cross-platform shared file open with share flags

Project description

Sharedfile

Easily let multiple Python processes read from and write to the same file at once.

A simple, cross-platform Python extension that makes it safe and easy for different processes to open and use the same file at the same time—perfect for logging, sharing data, or coordinating between programs.

Features

  • Super simple API: sharedfile.open(path, mode="r", share="rw")
  • Works on Windows and POSIX (Linux/macOS)
  • Lets you control how files are shared (Windows)
  • Uses advisory locking for safe sharing on POSIX systems
  • Feels just like Python’s built-in open

Installation

Install directly from PyPI:

pip install sharedfile

View on PyPI

Or build and install manually:

python setup.py build
python setup.py install

Usage Example

Let two processes write to and read from the same file:

import multiprocessing
import time
import sharedfile

def writer():
    with sharedfile.open("shared_test.txt", mode="w", share="rw") as f:
        for i in range(5):
            line = f"Writer line {i}\n"
            f.write(line)
            f.flush()
            print(f"[Writer] wrote: {line.strip()}")
            time.sleep(1)

def reader():
    time.sleep(0.5)  # Let writer start first
    with sharedfile.open("shared_test.txt", mode="r", share="rw") as f:
        for _ in range(5):
            f.seek(0)
            content = f.read()
            print(f"[Reader] read:\n{content.strip()}")
            time.sleep(1)

if __name__ == "__main__":
    p1 = multiprocessing.Process(target=writer)
    p2 = multiprocessing.Process(target=reader)
    p1.start()
    p2.start()
    p1.join()
    p2.join()

API

sharedfile.open(path, mode="r", share="rw")
  • path: File path.
  • mode: File mode ("r", "w", "a", "r+", etc.).
  • share: (Windows only) Control who else can access the file:
    • "r": Let others read
    • "w": Let others write
    • "rw": Let others read and write
    • (Ignored on POSIX; uses advisory locking)

Returns: A Python file-like object.

Platform Details

  • Windows: Uses native Win32 APIs for explicit read/write sharing.
  • POSIX: Uses advisory fcntl locking for cooperative sharing.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Author

Jan Bremec

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sharedfile-0.8-cp314-cp314t-win_amd64.whl (12.3 kB view details)

Uploaded CPython 3.14tWindows x86-64

sharedfile-0.8-cp314-cp314t-win32.whl (11.8 kB view details)

Uploaded CPython 3.14tWindows x86

sharedfile-0.8-cp314-cp314-win_amd64.whl (12.3 kB view details)

Uploaded CPython 3.14Windows x86-64

sharedfile-0.8-cp314-cp314-win32.whl (11.8 kB view details)

Uploaded CPython 3.14Windows x86

sharedfile-0.8-cp313-cp313-win_amd64.whl (12.2 kB view details)

Uploaded CPython 3.13Windows x86-64

sharedfile-0.8-cp313-cp313-win32.whl (11.7 kB view details)

Uploaded CPython 3.13Windows x86

sharedfile-0.8-cp312-cp312-win_amd64.whl (12.2 kB view details)

Uploaded CPython 3.12Windows x86-64

sharedfile-0.8-cp312-cp312-win32.whl (11.7 kB view details)

Uploaded CPython 3.12Windows x86

sharedfile-0.8-cp311-cp311-win_amd64.whl (12.2 kB view details)

Uploaded CPython 3.11Windows x86-64

sharedfile-0.8-cp311-cp311-win32.whl (11.7 kB view details)

Uploaded CPython 3.11Windows x86

sharedfile-0.8-cp310-cp310-win_amd64.whl (12.2 kB view details)

Uploaded CPython 3.10Windows x86-64

sharedfile-0.8-cp310-cp310-win32.whl (11.7 kB view details)

Uploaded CPython 3.10Windows x86

sharedfile-0.8-cp39-cp39-win_amd64.whl (12.2 kB view details)

Uploaded CPython 3.9Windows x86-64

sharedfile-0.8-cp39-cp39-win32.whl (11.7 kB view details)

Uploaded CPython 3.9Windows x86

sharedfile-0.8-cp38-cp38-win_amd64.whl (12.1 kB view details)

Uploaded CPython 3.8Windows x86-64

sharedfile-0.8-cp38-cp38-win32.whl (11.6 kB view details)

Uploaded CPython 3.8Windows x86

File details

Details for the file sharedfile-0.8-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 4c49b6fed7a3d4cc8a3a798878619b044cc71caa6656d8ca60dc09e77148ef90
MD5 c5e96f62cd71ce82490ab9ea26d9b9fb
BLAKE2b-256 fa3358c385619e4abe5bebd3afc6f8dd65e66c4e1db3094be7074709b8a76eab

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp314-cp314t-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp314-cp314t-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp314-cp314t-win32.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: CPython 3.14t, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 632a1bb1b1306cae5bc4b56c6591a63a013edbdf056ac07f8576ac7fd11ccf36
MD5 d9d037aa5167ba64518b3b01a7132100
BLAKE2b-256 064e44aaf611362e69bf04f00464509f0d4e2c23228b91fb6fc1cb3dc80d8a9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp314-cp314t-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2b90a8c3859105d9b66efbad917c859e09a789a6f1d3347933db8f47f0d66fda
MD5 03bb3e93458638eb5fd11902785499da
BLAKE2b-256 3777804387618d94c6c0f819017a39b35f922b6472905c249a162f66c62018f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp314-cp314-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp314-cp314-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp314-cp314-win32.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: CPython 3.14, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 388d6dec50cdb233c3bf63eb0151fa955b9b76cf2d71ff5508b0f1242d364747
MD5 59ff4b9f8be91abcf78a0af2c8c1f00b
BLAKE2b-256 301ca0accee49e1f9887cab21168e9c4eaa72c52c4525804470b0b6a8d140d15

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp314-cp314-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d0a33fbd6d88118d0e08185a6bad94b12c36bba771d13b4ed548ebb8538092d6
MD5 a6db9331aaf180062d2884326cc53c18
BLAKE2b-256 54e596c4f9203ee1cacf3c90971005ddf58464ab57b1714245fff07f67622278

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp313-cp313-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp313-cp313-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp313-cp313-win32.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 89d800a00ca566005d002932815c6ce58854dfae0ba428ada88f1e5db21fdd30
MD5 df40a4a3c5303ba220b568e400f84d34
BLAKE2b-256 ccae03a3d601a8f7130cc254821f7000c1df22fbc32f81fc7a4a110583ab1277

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp313-cp313-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 40f216f893352e8e7af5eefc30555c246ac57f9ce01b114ca7b402c70c7a8194
MD5 698b62daefd8c1301658c1248040f781
BLAKE2b-256 fc7f678f149a757412d59a575222054545dd33b64038822af4d95006d4814442

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp312-cp312-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp312-cp312-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp312-cp312-win32.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 e8ce51c029c6864e1ecfc6a40b0daa8a0b5694ce686e1ac04e2fd1e0945ec251
MD5 256c970426b032e7a6ee1c83c3512b4f
BLAKE2b-256 abe8a95c03bd752656b61f22f97758c7b7d603bb0fb9f0852a8623df4f498a9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp312-cp312-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9da8d850755c75096c770f137c6ca1d7a7482286663908339e0752a9b4af65c8
MD5 ebbda13db6a88b596fee1b6b9003acb6
BLAKE2b-256 1c9f8d525448675b45311c7e0302fa256568dc2aaecdc183ef9399670099723a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp311-cp311-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp311-cp311-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp311-cp311-win32.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 9f53f3574861577dab6422ddd485dd92df057b603ac5ce165ebc09a5a7eb87e4
MD5 4de56da3c7828d8fa5ee65adf04c7290
BLAKE2b-256 add77d39072397345e4a796ac856794a03e52ed41fc361e7e1b9d296aca4f814

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp311-cp311-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f9961385a77d11ef3f7c1e1a0de39c5bff13aa4e4660775784642072d6d422d9
MD5 c29535eaeb281cc6eae40f346e0970f9
BLAKE2b-256 59ccd3a8315789b01ba7797a7f12df8dee1540148c9aa326845cf508e4ae1d23

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp310-cp310-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp310-cp310-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp310-cp310-win32.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 da6d4f2936519dd6b846f156ae3ec9d70e2ff94cf3524c7397d60595fbab0e35
MD5 c55b17717c09417c3d754f0dd9dc90bf
BLAKE2b-256 12c7bc23258892023901c749754f083e82346479729c15be0651df00120a858a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp310-cp310-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 17d15bb0fd7c2cd156add44fe7d80c90c28a2a1626d2711dc1de00a224e4ae62
MD5 d1fa2385ca77a0074bc41982bbcb27f3
BLAKE2b-256 6a0c5c7cb63f7750e51770e0d6dd4a70f08eeee743337ea51fd06df23fb0183f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp39-cp39-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp39-cp39-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp39-cp39-win32.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 d4e8ada4e87e8a6ad69edae122230b6cd48b54a3719fcbd5e5bd231b242d909f
MD5 2beed28c9b8dfe543974427c168de155
BLAKE2b-256 ff2b0a72ebfbf5a62ef072577fdf7cf832966234e90442e1f438cc0cccfc1ddd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp39-cp39-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.8-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e9b3b85eebd7569a793dbb2c0302ff40feec89529b3b8585d84ab5875e9ba6a4
MD5 8f5012c15235f0b397674a49263936eb
BLAKE2b-256 58256110da454bcff57f90dc0041cf83905c46e40f6010c2c81fa5967a5d4eef

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp38-cp38-win_amd64.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sharedfile-0.8-cp38-cp38-win32.whl.

File metadata

  • Download URL: sharedfile-0.8-cp38-cp38-win32.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sharedfile-0.8-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 0c4f7229a770d99569568d60a9b1b7447bb4e0842eaa5cc66325796d742a02e7
MD5 531706733c84684b23163e4f4771ad86
BLAKE2b-256 47463891cac54a6cebefcfff15602e3353248bb1151af090000dd9a8db519ab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.8-cp38-cp38-win32.whl:

Publisher: workflow.yml on JanBremec/sharedfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page