Skip to main content

Reimplement threading.Lock 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.

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.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pthreading-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c503ae158fc035b8fee0c2409bdf7b4f40bb2ddf644ae1a39a0548c3d020cf00
MD5 d8d958dd32a9fc76fe0d143bcd64174a
BLAKE2b-256 c00c649aee3eb4c9da53983f20d58682103d13ebdf9a3cf2f3273727803e20c3

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

0.1.1

1 file

This release

0.1.0 This release

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