diff --git a/docs/index.rst b/docs/index.rst index 416955c7e8870d3a89f33a7eb0b3af874b8cc33b..c705bc32c867f5ed8ca86adff4b31700f2cdb74a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,7 +16,6 @@ Welcome to satella's documentation! exception_handling json posix - recipes Indices and tables diff --git a/docs/recipes.md b/docs/recipes.md deleted file mode 100644 index ac7cd12b6559ab1d2ee6aa03e3a861a110112d41..0000000000000000000000000000000000000000 --- a/docs/recipes.md +++ /dev/null @@ -1,48 +0,0 @@ -# Recipes - -How to do common things. - -## Check if running as root - -**__This can run only on POSIX. This will raise ImportError on non-POSIX platforms, such as MS Windows__** - -```python -from satella.posix import is_running_as_root -if is_running_as_root(): - print('Root!') -else: - print('Not root') -``` - - -## Acquire a PID lock file - -**__This can run only on POSIX. This will raise ImportError on non-POSIX platforms, such as MS Windows__** - -Use a context manager, _AcquirePIDLock_ from module _satella.pid_. Example: - -Example: -```python -from satella.posix import AcquirePIDLock - -with AcquirePIDLock('satella.pid'): - print('Lock is acquired!') - -print('Now lock is acquired!') -``` - -_AcquirePIDLock_ accepts extra keyword parameters: -* base_dir (default _/var/run_) - base directory of PID lock files -* delete_on_dead (default False) - if lock exists, but it's holder is dead, - remove the lock file and retry. - -Entering _AcquirePIDLock_ context may throw: - -* _AcquirePIDLock.FailedToAcquire_ - base class for errors. Thrown if can't read the file -* _AcquirePIDLock.LockIsHeld_ - lock is already held. This has two attributes - pid (int), the PID of holder, - and is_alive (bool) - whether the holder is an alive process - - -It is safe (and advisable!) to fork() inside this context manager. - -Writing to _/var/run_ may require root permissions. diff --git a/satella/__init__.py b/satella/__init__.py index 5ce5a63d753a348e0650d9f0225e2d0c6bbe3a9b..6c090996de58810152cd046000b8cf67f1e56d7f 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1,2 +1,2 @@ # coding=UTF-8 -__version__ = '2.2.2a2' +__version__ = '2.2.2a3'