Skip to main content

Reimplement threading.Lock, RLock and Condition with libpthread

The pthreading module provides Lock and Condition synchronization objects compatible with Python native threading module. The implementation, however, is based on POSIX thread library as delivered by the libpthread. Lock and Condition are designed to be a drop-in replacement for their respective threading counterpart.

Take a look at threading.py of Python 2. Notice that Event.wait() wakes 20 times a second and checks if the event has been set. This CPU hogging has been fixed in Python 3, but is not expected to change during Python 2 lifetime.

To avoid this waste of resources, put in your main module:

import pthreading
pthreading monkey_patch()

This would hack the Linux-native threading module, and make it use Linux-native POSIX synchronization objects.

The pthreading code was originally written as part of Vdsm by Cyril Plisko, Saggi Mizrahi and others. For questions, comments and patches please contact vdsm-devel.

Metadata

Release files for pthreading 0.1.3-3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pthreading 0.1.3-3
File Size Uploaded
pthreading-0.1.3-3.tar.gz 3.7 kB Details

Release files / pthreading-0.1.3-3.tar.gz

Download URL pthreading-0.1.3-3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a3d0d6b7c633455c364196aefc007e1178569019152444c5a1a79917bb7fd4b4
BLAKE2b-256 checksum
How to use checksums
6f0776fb656248635abb48d158fb37a843840e0187fe46e528b51187ace9a06a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3-3 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page