langacore.kit.common 0.2.4 documentation

This Page

langacore.kit.concurrency.synchronization

langacore.kit.concurrency.synchronization

Implements a reusable Java-like synchronization decorator. It is using threading locks or filesystem-based locks to synchronize subsequent calls of the specified functions. The former kind of lock is reentrant, the latter is not.

For filesystem-based locks the module is using Skip Montanaro’s lockfile library, compatible with Windows and POSIX environments.

Note

Instead of importing the whole structure, a recommended shortcut is available. Use from langacore.kit.concurrency import synchronized.

Functions

synchronized(func=None, lock=None, path=None)

Synchronization decorator.

Parameters:
  • lock – the user can specify a concrete lock object to be used with this specific synchronization decorator. This is useful when a group of functions should be synchronized together.
  • path – instead of using threading-based locking, file-based locks may be used instead. Beware, these are radically less performant than threading locks.