你正在阅读 Celery 3.1 的文档。开发版本文档见: 此处.
Utilities dealing with platform specifics: signals, daemonization, users, groups, and so on.
Return string identifying the current Python implementation.
Return the maximum number of open file descriptors on this system.
参数: | default – Value returned if there’s no file descriptor limit. |
---|
Pidfile
This is the type returned by create_pidlock().
TIP: Use the create_pidlock() function instead, which is more convenient and also removes stale pidfiles (when the process holding the lock is no longer running).
Create and verify pidfile.
If the pidfile already exists the program exits with an error message, however if the process it refers to is not running anymore, the pidfile is deleted and the program continues.
This function will automatically install an atexit handler to release the lock at exit, you can skip this by calling _create_pidlock() instead.
返回: | Pidfile. |
---|
Example:
pidlock = create_pidlock('/var/run/app.pid')
Detach the current process in the background (daemonize).
参数: |
|
---|
Example:
from celery.platforms import detached, create_pidlock
with detached(logfile='/var/log/app.log', pidfile='/var/run/app.pid',
uid='nobody'):
# Now in detached child process with effective user set to nobody,
# and we know that our logfile can be written to, and that
# the pidfile is not locked.
pidlock = create_pidlock('/var/run/app.pid')
# Run the program
program.run(logfile='/var/log/app.log')
Parse user id.
uid can be an integer (uid) or a string (user name), if a user name the uid is taken from the system user registry.
Parse group id.
gid can be an integer (gid) or a string (group name), if a group name the gid is taken from the system group registry.
Compat version of os.initgroups() which was first added to Python 2.7.
Version of os.setgid() supporting group names.
Version of os.setuid() supporting usernames.
Change process privileges to new user/group.
If UID and GID is specified, the real user/group is changed.
If only UID is specified, the real user is changed, and the group is changed to the users primary group.
If only GID is specified, only the group is changed.
Set the ps name for the currently running process.
Only works if setproctitle is installed.
Set the ps name using the multiprocessing process name.
Only works if setproctitle is installed.
Get errno for string, e.g. ENOENT.
Context manager to ignore specific POSIX error codes.
Takes a list of error codes to ignore, which can be either the name of the code, or the code integer itself:
>>> with ignore_errno('ENOENT'):
... with open('foo', 'r') as fh:
... return fh.read()
>>> with ignore_errno(errno.ENOENT, errno.EPERM):
... pass
参数: | types – A tuple of exceptions to ignore (when the errno matches), defaults to Exception. |
---|