From c20123bc678fbccf6e3e7631d26a18d4086c6fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Mon, 30 Dec 2019 21:20:43 +0100 Subject: [PATCH] recipes removed --- docs/index.rst | 1 - docs/recipes.md | 48 --------------------------------------------- satella/__init__.py | 2 +- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 docs/recipes.md diff --git a/docs/index.rst b/docs/index.rst index 416955c7..c705bc32 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 ac7cd12b..00000000 --- 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 5ce5a63d..6c090996 100644 --- a/satella/__init__.py +++ b/satella/__init__.py @@ -1,2 +1,2 @@ # coding=UTF-8 -__version__ = '2.2.2a2' +__version__ = '2.2.2a3' -- GitLab