Skip to main content

threading and communication/synchronisation conveniences

Project description

Thread related convenience classes and functions.

Class AdjustableSemaphore

A semaphore whose value may be tuned after instantiation.

Function bg(func, daemon=None, name=None)

Dispatch the callable func in its own Thread; return the Thread.

Parameters: daemon: optional argument specifying the .daemon attribute. name: optional argument specifying the Thread name.

Class LockableMixin

Trite mixin to control access to an object via its ._lock attribute. Exposes the ._lock as the property .lock. Presents a context manager interface for obtaining an object's lock.

Function locked(func)

A decorator for monitor functions that must run within a lock. Relies upon a ._lock attribute for locking.

Function locked_property(func, lock_name='_lock', prop_name=None, unset_object=None)

A thread safe property whose value is cached. The lock is taken if the value needs to computed.

Function via(cmanager, func, *a, **kw)

Return a callable that calls the supplied func inside a with statement using the context manager cmanager. This intended use case is aimed at deferred function calls.

Class WorkerThreadPool

MRO: cs.resources.MultiOpenMixin, cs.obj.O
A pool of worker threads to run functions.

Class WTPoolEntry

MRO: builtins.tuple
WTPoolEntry(thread, queue)

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

cs.threads-20190102.tar.gz (5.3 kB view hashes)

Uploaded Source

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