aiosubprocess-2021.5.3
توضیحات
A zero-dependency async subprocess that keeps on getting stdout and stderr.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX |
| نام فایل | aiosubprocess-2021.5.3 |
| نام | aiosubprocess |
| نسخه کتابخانه | 2021.5.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Samuel Giffard |
| ایمیل نویسنده | samuel@giffard.co |
| آدرس صفحه اصلی | https://github.com/Mulugruntz/aiosubprocess |
| آدرس اینترنتی | https://pypi.org/project/aiosubprocess/ |
| مجوز | - |
| Usage | Release | Development |
|----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [](LICENSE) | [](https://pypi.org/project/aiosubprocess/) | [](https://github.com/Mulugruntz/aiosubprocess/actions) |
| [](https://pypi.org/project/aiosubprocess/) | [](https://github.com/Mulugruntz/aiosubprocess/tags) | [](https://codeclimate.com/github/Mulugruntz/aiosubprocess/maintainability) |
| [](https://pypi.org/project/aiosubprocess/) | [](http://calver.org/) | [](https://codeclimate.com/github/Mulugruntz/aiosubprocess/test_coverage) |
| [ ](https://pepy.tech/project/aiosubprocess) | | [](https://github.com/python/black) |
# aiosubprocess
A **zero-dependency** async subprocess that keeps on getting stdout and stderr.
## How to use
#### Example 1: Hello World
A classic Hello World. It prints `Hello World!` in the shell and
redirects the stdout to `print()`.
```python
import asyncio
from aiosubprocess import Process
asyncio.get_event_loop().run_until_complete(
Process("echo Hello World!", stdout=print).shell()
)
```
```shell
$> python ex1_minimal.py
[AIO Subprocess-0] Hello World!
Process finished with exit code 0
```
#### Example 2: Two Processes
One process writes to a file, and a second process logs the content of the file
in real time.
```python
import asyncio
from aiosubprocess import Process
loop = asyncio.get_event_loop()
reader = Process(
"""for i in {1..5}
do
echo "Hello $i World" > tempfile.log
sleep 1
done""",
loop=loop,
name="Writer",
)
writer = Process(
"timeout --foreground 10s tail -f tempfile.log",
loop=loop,
name="Reader",
expected_returncode=124, # Because timeout is expected
)
awaitable_reader = reader.shell()
awaitable_writer = writer.shell()
gathered = asyncio.gather(awaitable_reader, awaitable_writer, loop=loop)
asyncio.get_event_loop().run_until_complete(gathered)
assert gathered.result() == [True, True]
```
Which does exactly this:

## Why?
There are many scenario where we need to keep an eye on
a subprocess output. If we want to do so in realtime
(and redirect it to logs or a GUI), the boilerplate is
tedious.
The other solution is to wait for the subprocess to
exit and read the stdout/stderr afterwards.
This library implements this boilerplate, so you don't have to.
نیازمندی
| مقدار | نام |
|---|---|
| - | pytest |
| - | coverage |
| - | pytest-asyncio |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl aiosubprocess-2021.5.3:
pip install aiosubprocess-2021.5.3.whl
نصب پکیج tar.gz aiosubprocess-2021.5.3:
pip install aiosubprocess-2021.5.3.tar.gz