Registry / http-networking / sysv-ipc

sysv-ipc

JSON →
library1.2.0pypypi✓ verified 89d ago

sysv-ipc is a Python library that provides interfaces to System V Inter-Process Communication (IPC) primitives: semaphores, shared memory, and message queues. These mechanisms allow separate processes on the same machine to communicate and synchronize. The current version is 1.2.0, and the project has an active maintenance cadence on GitHub, primarily supporting Python 3.

pip install sysv_ipc
INSTALL
IMPORT
SIG · SYSV-IPC
S
sysv-ipc
http-networkingpythonv1.2.0
Install
1.5s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Semaphore
✓ from sysv_ipc import Semaphore
SharedMemory
✓ from sysv_ipc import SharedMemory
MessageQueue
✓ from sysv_ipc import MessageQueue
IPC_PRIVATE
✓ from sysv_ipc import IPC_PRIVATE
ftok
✓ from sysv_ipc import ftok

This quickstart demonstrates the creation, acquisition, release, and removal of a semaphore. In a real multi-process application, processes would share a key (e.g., generated by `sysv_ipc.ftok`) to synchronize access to shared resources.

import sysv_ipc import time import os # IPC_PRIVATE creates a new unique semaphore set for demonstration. # For multi-process communication, use a shared key, e.g., # key = sysv_ipc.ftok(os.getcwd(), 1) try: # Create a semaphore set with 1 semaphore, initial value 1. # IPC_CREX ensures exclusive creation, raising an error if it exists. sem = sysv_ipc.Semaphore(sysv_ipc.IPC_PRIVATE, flags=sysv_ipc.IPC_CREX, initial_value=1) print(f"Semaphore created with key: {sem.key}") print("Attempting to acquire semaphore...") sem.acquire() # Decrement semaphore value by 1 print("Semaphore acquired. Simulating work...") time.sleep(0.5) sem.release() # Increment semaphore value by 1 print("Semaphore released.") # It's crucial to remove IPC objects after use to free system resources. sem.remove() print("Semaphore removed.") except sysv_ipc.ExistentialError: print("Semaphore with this key already exists. This quickstart uses IPC_PRIVATE to avoid conflicts.") print("For multi-process, use sysv_ipc.ftok(path, id) for a shared key and omit IPC_CREX.") except sysv_ipc.Error as e: print(f"An IPC error occurred: {e}")
Debug
Known issues
breakingVersions of sysv-ipc from 1.0.0 onwards are strictly Python 3 compatible. Earlier versions might target Python 2 or have significantly different behavior/APIs.
fix
Ensure you are using Python 3. For Python 2, consider the `sysv_ipc_py2` fork or older `sysv-ipc` versions if absolutely necessary, but these are no longer maintained.
affects: >=1.0.0
gotchaSysV IPC objects (semaphores, shared memory, message queues) persist in the system kernel even after the creating process terminates. Failing to explicitly remove them will lead to resource leaks.
fix
Always call the `.remove()` method on IPC objects when they are no longer needed. In production, implement robust cleanup routines (e.g., signal handlers, daemon shutdown hooks).
affects: All
gotchaWhen using `sysv_ipc.ftok(path, id)` to generate a common key, the `path` argument must refer to an existing, accessible file or directory on the filesystem.
fix
Ensure the specified `path` exists and the process has read/execute permissions for it. Using `os.getcwd()` for simple demos is common, but in production, use a stable, known file path.
affects: All
gotchaAttaching to an existing `SharedMemory` segment with a `size` parameter that does not match its original creation size will result in an `OSError: [Errno 22] Invalid argument`.
fix
When attaching to an existing shared memory segment, either omit the `size` parameter (which will infer it from the existing segment) or ensure the provided `size` exactly matches the size used during its creation.
affects: All
Errors
Common errors & fixes
OSError: [Errno 13] Permission denied
The current user or process lacks the necessary permissions to create, access, or remove SysV IPC objects on the system.
fix
Check system IPC limits (`ipcs -l`), ensure appropriate user/group permissions for IPC objects (e.g., using `mode` flag during creation), or run the process with elevated privileges if appropriate (e.g., `sudo`).
OSError: [Errno 22] Invalid argument
Most commonly occurs when attaching to a `SharedMemory` segment with a `size` that doesn't match its original creation size, or providing an invalid key type.
fix
For SharedMemory, remove the `size` parameter when attaching to an existing segment, or ensure it exactly matches. For keys, ensure they are integers (or `IPC_PRIVATE`), not strings.
sysv_ipc.ExistentialError: [Errno 17] File exists
You are attempting to create an IPC object (Semaphore, SharedMemory, MessageQueue) using the `IPC_CREX` flag with a key that already has an associated IPC object.
fix
If you intend to create a new unique object, use `IPC_PRIVATE` or a key that is guaranteed not to be in use. If you intend to connect to an existing object, remove the `IPC_CREX` flag. You can also use `sysv_ipc.exists(key, type)` to check before attempting creation.
AttributeError: module 'sysv_ipc' has no attribute 'exist'
A common typo when trying to check if an IPC object exists.
fix
The correct function name is `sysv_ipc.exists(key, type)`, not `exist`.
Upgrade
Version history
1.2.0latest on PyPI · released Jan 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
sysv-ipc — pip install sysv-ipc · libregistry