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.

Download files

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

Source Distribution

pthreading-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file pthreading-0.1.1.tar.gz.

File metadata

  • Download URL: pthreading-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pthreading-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e857ea323c67ef1a2346d10c3fbfe706c528b7303f65ac1fc9500e289a49cc77
MD5 4ba7f5d60b0595ec82192746295bd5b0
BLAKE2b-256 b4d3d606ae1fe3bec956cbbe2a0b1ef0b96e468702a220c227789395fbf539eb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.3-3

1 file

0.1.3

1 file

0.1.2

1 file

This release

0.1.1 This release

1 file

0.1.0

1 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