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="r", 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.6-cp314-cp314t-win_amd64.whl (12.3 kB view details)

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14tWindows x86

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14Windows x86

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

sharedfile-0.6-cp39-cp39-win_amd64.whl (12.1 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9Windows x86

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8Windows x86

File details

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

File metadata

  • Download URL: sharedfile-0.6-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.6-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 8791750ceb470ad61a22359d54b5d055c1bbb1b67e2f877164f7b3ef77f941d8
MD5 6382ddc44b2b5f82822507e4b1712019
BLAKE2b-256 822cc264a8fadf93c6befe6d3442d600507b700b284f9aace8980545a9e18f71

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp314-cp314t-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 bf9046401695779d73bf52931dbc018d84d669c6e7e8cad3e60c7c292dfad8a8
MD5 154b14624e7d95abe128fcd772ee7f99
BLAKE2b-256 e12fc878b7738f9ce3c0657c541e4c890bda10f92518950393ddf74ec1220354

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8c1a5d007282f50ff3a03b90fb0b32f11d3ded779a2803b738012aed4218de95
MD5 63a4dce17ca6a448e21b88e768454d83
BLAKE2b-256 907f0a3dd2d13ffcf0294b9a06d9f6dc448fcb8f2ad8acce940209e4dbddd06e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp314-cp314-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 0b0ec2fe34fd9f437fa3bbe09e82bbd1f4cb8f90f5701bf491523b2a5da5ff9a
MD5 82e0b825260c4ae7ccbb9d1923212a53
BLAKE2b-256 fe5e7d8704c9eaa11f14a234f5e037d847f5e412139df26cdf24bc3aed84f78f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 eb4728f6238976e4489f586073abdd2f4bdc63427cafa688c5666f1a63deb5b4
MD5 8613fd685dcf38c66c5924ffbf1674ad
BLAKE2b-256 2a4c0df9d3ab7afd7daed03a86f3c6d7093d2d92b4ffa7d2c0460c0189eedc4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp313-cp313-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 5905d8561fc5679095d1ca3b698188f4c811be1dbafe4ad05558add139c769ed
MD5 c395421e5397caf04a9e6e8377c414b2
BLAKE2b-256 47739d6733232d2cf02ce3140c75de741c0b3a94bd92edd9ca69555e3e82029c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac4bb741ac3010172292fc989abd8041061cd8d367df09949167be6f1ec3c945
MD5 d22d27cbbda586fb0593a15bafb1309f
BLAKE2b-256 4abd758083c1476370b264440d3f315e81f7beecd724ac25f16f3ec05e1e40f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp312-cp312-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 fffbf0f152d712b2615e11c22c2a4420198055ca6ce4f75dff4933f1b3e71ecb
MD5 235a282577f440ba78c79c42db3fbe25
BLAKE2b-256 de4ae45d3b2a9559da70d2854b2b2128fa1b817849f174ba71eae6d33244ec5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a767d10e0fb444349f6984f3949548dccc1c5c75f167c33dfc8550fd809e31e5
MD5 f40ecc1650aa1c024352e71f6631bff5
BLAKE2b-256 38391bd1786d4149e285e05098f6450459532f74d12d1c10b4310a7b1cbbbe04

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp311-cp311-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 7ef619dd7d338d3aa9407c1bdd9c48fb9c7992eab27cd70c6a7175ae6655e3ec
MD5 57e78a920cbe9ece99400b0c352d6f54
BLAKE2b-256 142f441f0b6585842af8099347522ef563472cf39991f6ea24f99961c876a551

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ed1bb4815fdf490cf7fd514b2ae3b034e1b0df852216dc4f11d4aabe3c12828e
MD5 4835743b6c04ee30ec5e0031625abfbf
BLAKE2b-256 5f9012a420be1a87573dbf57a702da9b38baf04bef1f78954224c6c5f0b20e67

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp310-cp310-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7d7bf9346cf1f8f487bb3f0a6edd2e422ead7d7d4281a66433bc1fc5aeb6be0b
MD5 d0106adccfdcdd64fe2b86c044b266f7
BLAKE2b-256 37851f2733ac01b4fa2a504fbb66de73c63b3ea397c99afe1590f2d39cb52fc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 12.1 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.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1654aa8d6cc9862bafe89a57c080a6e42f234a8c6887f8519891c54b2eb070ef
MD5 ce226dc8ca9d8e16b495df7be0869d58
BLAKE2b-256 2bd9572a9ea781088911b4ab6a7b753af3ca9d2acd387f6b6d113a3f1688efb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp39-cp39-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 f364cf1b14f65b8a2a1f75e94fbf19f196318dce1e8d1ff3027210428d840d48
MD5 e4cc7af5d660939ee414b8812b400d00
BLAKE2b-256 3b00bc67c8a059476c5dc232e708ee78c6d2d628b9af85bb8e38986298e50f94

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 96321f1c41d63751428b4e7bcca3ddc8af6932c5c0fde29884276896002564da
MD5 188ba98131b4a22ace0fdc54f5892417
BLAKE2b-256 2ffb82b8053e8ebc99adb80ad67c92f2b63ce5186358d607cfec10f0a74ab547

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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.6-cp38-cp38-win32.whl.

File metadata

  • Download URL: sharedfile-0.6-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.6-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 7c435c9ac78621ac9a593606c542e47f8212ae076d2861ee0e9d82df0dbe2bcf
MD5 0798cc868e97f9ce637000837640cc5c
BLAKE2b-256 184a6aee98cf127c4759583ad2e40b0e86b51bbf044e43bc6385698dda1838a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sharedfile-0.6-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