bgprocess
Reads the output of a process line-by-line with a time limit.
Tested on Linux and macOS with Python 3.7-3.9.
Install
$ pip3 install bgprocess
Use
from bgprocess import BackgroundProcess, LineWaitingTimeout
with BackgroundProcess(["some_program", "arg1", "arg2"]) as process:
# The process is already up and running in background.
# We can continue to perform operations in our program
do_something()
do_something_more()
# ok, let's check how the process is doing
try:
# getting for the first line from the process output.
# If no line was output, this call will wait for the line
# and only then will return the result
str1 = process.next_line()
# waiting for the second line from the process output
str2 = process.next_line()
# waiting for the next line, but not too long.
# If the line does not appear in 0.25 seconds,
# LineWaitingTimeout exception will be raised
str3 = process.next_line(read_timeout = 0.25) # 0.25 seconds
# skipping lines until we get the line matching the condition
str4 = bp.next_line(match = lambda line: line.startswith('a'))
# skipping lines until we get the line matching the condition.
# If the mathing line does not appear in 3 seconds,
# LineWaitingTimeout exception will be raised
str5 = process.next_line(
match = lambda line: line.startswith('a'),
match_timeout = 3)
except LineWaitingTimeout:
# we may get this exception when running next_line with
# read_timeout or match_timeout
print("Timeout!")
If the process is finished, next_line returns None instead of a str.
Metadata
Release files for bgprocess 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bgprocess-1.1.1.tar.gz | 6.8 kB | Without provenance | Details for bgprocess-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bgprocess-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for bgprocess-1.1.1-py3-none-any.whl |
Total release size: 14.0 kB
Release files / bgprocess-1.1.1.tar.gz
| Download URL | bgprocess-1.1.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f2d3440ca89cbd2719ce1b6bccda3c6294cf3c1775af594a67f1c38a0eadc1f
|
|
BLAKE2b-256 checksum How to use checksums |
138380fe8ba656757e9622a5e05571053f3ff5cadf3d64fc24f709ac8a210f5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / bgprocess-1.1.1-py3-none-any.whl
| Download URL | bgprocess-1.1.1-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
daea139e68cfdfdbf45a5f216a816c2d1cdbeeb2b9af77c905c852e685fd5db4
|
|
BLAKE2b-256 checksum How to use checksums |
2769fba76f00b85d176597c59f4c00b35a614de5714e0e428d416dd387290d3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Security for bgprocess 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.