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.3-cp314-cp314t-win_amd64.whl (12.3 kB view details)

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14tWindows x86

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14Windows x86

sharedfile-0.3-cp313-cp313-win_amd64.whl (12.1 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9Windows x86

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8Windows x86

File details

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 388f6edb597238b90677ba997a0a98f6d03c8b226cf27ee248f0b88887e07494
MD5 86f1b1018498ce7d86d725aa391a3048
BLAKE2b-256 b591c9c4b8a6622da56b9811e123453c840a90b3ee43bded4c60b5554228ce92

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 c1fa120e4c03bcc1cd47c5d108151a149959956ec8bb353edd7cab3ab1a7272a
MD5 c3f5aae31cc39cbb6a82ee3a57fd9956
BLAKE2b-256 1b9ea59579c155528ee1c66c12c2c92171b83b848f5761c5db17228c47d91e1e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b8aee2dc067d927e6b658b36afd9f5d5991ef016d06b385f6fc67c0305f8b748
MD5 21e0ee096f83b35bdb6de45ae3b1b420
BLAKE2b-256 5ae4617275c1c0f2e789ec0f32b28ac47ab46b9df42585d4fb0faa9216e5dd94

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 c477356cb177e4a32d21c80b4a9bf9acdaa075cc61b1146142dc13840480d01a
MD5 c606ff8998209beebcd5464dd74031e4
BLAKE2b-256 f8ed081fac833f726ba21183966838d03f26e5929e6562e2b4e992e34980c686

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.1 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9e72aaa6ac5b5781a591aa3a1ea7ff1e39b00b23ebadecca246104dbac04aa7a
MD5 dc29a2d974efd957f5f08a23cd9731d9
BLAKE2b-256 7fa79618a0701d525eb3ed679fb5ceae05bc9548e663a9588506dbe27881763e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 3b64966f1ef7535cb953253a8ccfea18bb0cad6d49f86609ae308b8166237381
MD5 a1c28210e64e5851f9ce9673fb1544cb
BLAKE2b-256 f583b3be3219402bf5fa9c2e1f842b53bddcc5b956312a67d6bef786a52b0a6c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8d01f1db6874b86aff97035f2f0da18bdd8a573c760e1cc66119fcd99da106cd
MD5 aa3d3bbd2cf30fd73a18809a365109bc
BLAKE2b-256 faacc4132f0436a3e0b7116763db1eb259eee3196eb243f6a328f3db2ba16e0e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 c82ddb97fd81fc1e58b02ee45af375ed39e081cb36e94ceb9e4d6402ff23fb8e
MD5 2cd19f221dd5cbdd9653b68804b6c677
BLAKE2b-256 d92d03b388209da5437c8aa2d0cc78105f16c1f4f82b8c487db826b43365924a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ddb6af625c7e1ad89b76b08e9e7967e7b7902a160898fa61a577c8424c25fc83
MD5 093141f1f816f6cc86e23a5b70b1fbc7
BLAKE2b-256 c3957f124b85a3cf538f03091bca1bdb70eb256bc375671785ffa64cfa9b244b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 50efeaa138791a27f80d74981c7396571357c0eb90327bfb65c6a1f468f95899
MD5 49eee6f31c921f1547d82c9cd7ffc4c9
BLAKE2b-256 84c96da3dbf5808c8cc8a9e4bc6f90590edf0a620c7545015259871a75d5082f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f8afbdc2cd9d6d77f249aada66abfd87bf03af32cd9a9930db3d5e4e23b71741
MD5 772418d12041ef61ca4d887a0bd99626
BLAKE2b-256 6b336755078fd233aec64aa3fa58f773ef8bffee69901855dc5bf424af830adc

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 8ad3ae067877214ad699aef5a18400faed6514698a93dc17a244c8563e95c69a
MD5 8ec688664e8cd89cd2571fe64c44aaa4
BLAKE2b-256 134dfb9efda4e5aaf0c0eec22a2d5af8637a4abada48730130e9f2f467397238

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d0c60f097026686c75cc5c361f8e66d4f9a7236f553aff823c4efc084b17e9cc
MD5 ade1107ab3944a89729c3bada86624c1
BLAKE2b-256 7a7328a0555cf51ed4aba9bd0360fecb51120079e7e7d409273b2157dceaec4b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 9a14aaa9c9a1b86692119699204a79cb04f2757eb5baf1800c392ef3a58ad8bc
MD5 ce3bf83f3f277e6fb5522bf080a736d0
BLAKE2b-256 23c6cfd174fc3aac68568ad191a36d542fdc2a64100d0afdadc0e3008decf4fe

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 652494c96315031cb61f18198ce9516957e58774bba1b2d0d74897bee6259266
MD5 07b02bac5501c1a03e988749977c4cae
BLAKE2b-256 f3c48825cf8a17b8e062c479e7a489c026463febe16dc9a02de101c336d1b6f3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sharedfile-0.3-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.3-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 00e6dd8164cfcc4fc86f27c92866e24195bfda4c2a97d06f2e63aab697d62979
MD5 bcdf1fa362aaaae0eb05865cbfc328e9
BLAKE2b-256 0d1d9d0b744cec3bb773400db526cee70f8a76cae40eecd8441e3afd8918178c

See more details on using hashes here.

Provenance

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