Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
c20123bc
Commit
c20123bc
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
recipes removed
parent
425db0d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/index.rst
+0
-1
0 additions, 1 deletion
docs/index.rst
docs/recipes.md
+0
-48
0 additions, 48 deletions
docs/recipes.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
with
1 addition
and
50 deletions
docs/index.rst
+
0
−
1
View file @
c20123bc
...
...
@@ -16,7 +16,6 @@ Welcome to satella's documentation!
exception_handling
json
posix
recipes
Indices and tables
...
...
This diff is collapsed.
Click to expand it.
docs/recipes.md
deleted
100644 → 0
+
0
−
48
View file @
425db0d5
# 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.
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
c20123bc
# coding=UTF-8
__version__
=
'
2.2.2a
2
'
__version__
=
'
2.2.2a
3
'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment