exopy.tasks.tasks.shared_resources module

Thread safe object to use in tasks.

class exopy.tasks.tasks.shared_resources.SharedCounter[source]

Bases: atom.atom.Atom

Thread-safe counter object.

count

Current count of the counter. User should not manipulate this directly.

increment()[source]

Increment the counter by one.

decrement()[source]

Decrement the counter by one.

class exopy.tasks.tasks.shared_resources.SharedDict(default=None, **kwargs)[source]

Bases: atom.atom.Atom

Dict wrapper using a lock to protect access to its values.

Parameters

default (callable, optional) – Callable to use as argument for defaultdict, if unspecified a regular dict is used.

safe_access(key)[source]

Context manager to safely manipulate a value of the dict.

locked()[source]

Acquire the instance lock.

get(key, default=None)[source]

Equivalent of dict.get but lock protected.

items()[source]

Equivalent of dict.items but lock protected.

class exopy.tasks.tasks.shared_resources.ResourceHolder(default=None, **kwargs)[source]

Bases: exopy.tasks.tasks.shared_resources.SharedDict

Base class for storing resources and handling releases and restting.

priority

Priority determining in which order resources will be released. Smallest values will be released earlier.

release()[source]

Release the resources held by this container.

This method should be safe to call on already released resources.

reset()[source]

Reset the resources.

This is different from releasing. This method is typically called when resuming a measurement to ensure that the state of the resources can be trusted inspite of the interruption.

class exopy.tasks.tasks.shared_resources.ThreadPoolResource(default=<class 'list'>, **kwargs)[source]

Bases: exopy.tasks.tasks.shared_resources.ResourceHolder

Resource holder specialized to handle threads grouped in pools.

priority

A value of type int.

By default, ints are strictly typed. Pass strict=False to the constructor to enable int casting for longs and floats.

release()[source]

Join all the threads still alive.

class exopy.tasks.tasks.shared_resources.InstrsResource(default=None, **kwargs)[source]

Bases: exopy.tasks.tasks.shared_resources.ResourceHolder

Resource holder specialized to handle instruments.

Each driver instance should be stored as a 2-tuple with its associated starter. (driver, starter)

release()[source]

Finalize all the opened connections.

reset()[source]

Clean the cache of all drivers to avoid corrupted value due to user interferences.

class exopy.tasks.tasks.shared_resources.FilesResource(default=None, **kwargs)[source]

Bases: exopy.tasks.tasks.shared_resources.ResourceHolder

Resource holder specialized in handling standard file descriptors.

release()[source]

Close all the opened files.