Assorted process management functions.
Function groupargv(pre_argv, argv, post_argv=(), max_argv=None, encode=False)
Distribute the array argv over multiple arrays
to fit within MAX_ARGV.
Return a list of argv lists.
Parameters:
pre_argv: the sequence of leading argumentsargv: the sequence of arguments to distribute; this may not be emptypost_argv: optional, the sequence of trailing argumentsmax_argv: optional, the maximum length of each distributed argument list, default: MAX_ARGVencode: default False. If true, encode the argv sequences into bytes for accurate tallying. Ifencodeis a Boolean, encode the elements with their .encode() method. Ifencodeis astr, encode the elements with their.encode()method withencodeas the encoding name; otherwise presume thatencodeis a callable for encoding each element.
The returned argv arrays will contain the encoded element values.
Function PidFileManager(path, pid=None)
Context manager for a pid file.
Parameters:
path: the path to the process id file.pid: the process id to store in the pid file, default fromos.etpid.
Writes the process id file at the start and removes the process id file at the end.
Function pipefrom(argv, trace=False, binary=False, keep_stdin=False, **kw)
Pipe text from a command.
Optionally trace invocation.
Return the Popen object with .stdout decoded as text.
Parameters:
argv: the command argument listbinary: if true (default false) return the raw stdout instead of a text wrappertrace: if true (defaultFalse), iftraceisTrue, recite invocation to stderr otherwise presume thattraceis a stream to which to recite the invocation.keep_stdin: if true (defaultFalse) do not attach the command's standard input to the null device. The default behaviour is to do so, preventing commands from accidentally consuming the main process' input stream.
Other keyword arguments are passed to the io.TextIOWrapper
which wraps the command's output.
Function pipeto(argv, trace=False, **kw)
Pipe text to a command. Optionally trace invocation. Return the Popen object with .stdin encoded as text.
Parameters:
argv: the command argument listtrace: if true (defaultFalse), iftraceisTrue, recite invocation to stderr otherwise presume thattraceis a stream to which to recite the invocation.
Other keyword arguments are passed to the io.TextIOWrapper
which wraps the command's input.
Function remove_pidfile(path)
Truncate and remove a pidfile, permissions permitting.
Function run(argv, logger=None, pids=None, **kw)
Run a command. Optionally trace invocation. Return result of subprocess.call.
Parameters:
argv: the command argument listpids: if supplied and not None, call .add and .remove with the subprocess pid around the execution
Other keyword arguments are passed to subprocess.call.
Function stop(pid, signum=<Signals.SIGTERM: 15>, wait=None, do_SIGKILL=False)
Stop the process specified by pid, optionally await its demise.
Parameters:
pid: process id. Ifpidis a string, treat as a process id file and read the process id from it.signum: the signal to send, defaultsignal.SIGTERM.wait: whether to wait for the process, defaultNone. IfNone, returnTrue(signal delivered). If0, wait indefinitely until the process exits as tested byos.kill(pid, 0). If greater than 0, wait up towaitseconds for the process to die; if it exits, returnTrue, otherwiseFalse;do_SIGKILL: if true (defaultFalse), send the processsignal.SIGKILLas a final measure before return.
Function write_pidfile(path, pid=None)
Write a process id to a pid file.
Parameters:
path: the path to the pid file.pid: the process id to write, defautl fromos.getpid.
Release files for cs-psutils 20190101
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs.psutils-20190101.tar.gz | 5.1 kB | Details |
Release files / cs.psutils-20190101.tar.gz
| Download URL | cs.psutils-20190101.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a72a8b72dedaebf86ddcdca80785c54e7ccbc82a45be256e587021c5cd6a88d7
|
|
BLAKE2b-256 checksum How to use checksums |
90ff12ec450eba15801606be549e3c69f8438e59eae69199e44a787c52e7323a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.0 CPython/3.6.6
|