Skip to main content

pywinpipe - Fast data exchange between 2 processes (Windows only)

Project description

pywinpipe - Fast data exchange between 2 processes (Windows only)

pip install pywinpipe

The pywinpipe module with the 2 classes: Write2Pipe and ReadFromPipe can be beneficial for people who need to establish inter-process communication (IPC) between different programs or components on a Windows system.

By utilizing named pipes, this module enables communication through a simple and efficient mechanism. Some potential beneficiaries of this module include:

Client-Server Applications: The module allows for communication between a client and a server process, facilitating data exchange and coordination between the two.

Inter-Process Communication: Developers can use this module to establish communication channels between different processes within a system, enabling them to exchange information or coordinate actions.

Automation and Scripting: System administrators can utilize this module to automate tasks or build scripts that involve communication between different components or programs.

Advantages of using named pipes for inter-process communication include:

Simplicity: Named pipes provide a straightforward and easy-to-use mechanism for communication between processes. They abstract away the complexities of lower-level protocols and offer a simple API for reading from and writing to the pipe.

Efficiency: Named pipes are efficient for communication within a single machine, as they leverage shared memory and kernel-level synchronization. This results in faster data transfer compared to other IPC mechanisms.

Security: Named pipes offer built-in security features, allowing for secure communication between processes. Access to the pipe can be controlled through permissions, ensuring that only authorized processes can read from or write to the pipe.

Overall, the Write2Pipe and ReadFromPipe module simplifies inter-process communication using named pipes, offering an efficient and reliable solution for data exchange and coordination between different components or programs on a Windows system.

  • Write2Pipe: Allows writing messages to a named pipe.
  • ReadFromPipe: Allows reading messages from a named pipe.
# create a file: pipewrite.py
from pywinpipe import Write2Pipe

with Write2Pipe(pipename=r"\\.\pipe\example",
                nMaxInstances=1,
                nOutBufferSize=65536,
                nInBufferSize=65536,
                timeout=0, ) as ba:
    for _ in range(10):
        ba.write_message(b"bababababa" * 2000)


# create another file: piperead.py
from pywinpipe import ReadFromPipe
import numpy as np

with ReadFromPipe(pipename=r"\\.\pipe\example", ) as baba:

    num = np.array([1])
    erx = baba.read_message()
    while len(num)>0:
        try:
            er = next(erx)
            num = np.frombuffer(er[0][:er[1]], dtype='S1')
            print(f'read {er[1]} bytes: {num}')
        except Exception:
            print(er)

# execute pipewrite.py and then piperead.py


# output  pipewrite.py:

# Waiting for clients
# Client connected

# output  piperead.py:

read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 20000 bytes: [b'b' b'a' b'b' ... b'a' b'b' b'a']
read 0 bytes: []

Project details


Download files

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

Source Distribution

pywinpipe-0.11.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pywinpipe-0.11-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file pywinpipe-0.11.tar.gz.

File metadata

  • Download URL: pywinpipe-0.11.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pywinpipe-0.11.tar.gz
Algorithm Hash digest
SHA256 4497248ee4c166fda4af5470769c2bbb95c81754481a4a3758329a6ac0e8ad75
MD5 924beb9d7092597034a7baa2612decfe
BLAKE2b-256 dc6aad775d60cbd810997ad688aca70e8e936e4796e9f97eeeba8df196299b3c

See more details on using hashes here.

File details

Details for the file pywinpipe-0.11-py3-none-any.whl.

File metadata

  • Download URL: pywinpipe-0.11-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pywinpipe-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 056ff0b08f7b26ee77a411e31e8e4c7b8c7c1d29dcbc6a84dbe7dbad363e8e9d
MD5 4df5921a734dd1a83a5acafa80ab7eed
BLAKE2b-256 353467b13543a5020710742525dc812c4e7fe401f1ffccbc86da2f7f9c742ef7

See more details on using hashes here.

Supported by

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