Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Jul 23, 2024
1 parent ba3ef8c commit 423f28f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ suby('python', '-c', 'print("hello, world!")')

## Run subprocess and look at the result

The `suby` function returns an object of the `SubprocessResult` class. It contains the following required fields:
The `suby` module is a callable object and can be imported like this:

```python
import suby
```

If you use static type checking and get an error that it is impossible to call the module, use a more detailed import form:

```python
from suby import suby
```

Functionally, these two import ways are identical.

When called `suby` returns an object of the `SubprocessResult` class. It contains the following required fields:

- **id** - a unique string that allows you to distinguish one result of calling the same command from another.
- **stdout** - a string containing the entire buffered output of the command being run.
Expand All @@ -63,8 +77,6 @@ The `suby` function returns an object of the `SubprocessResult` class. It contai
The simplest example of what it might look like:

```python
import suby

result = suby('python', '-c', 'print("hello, world!")')
print(result)
# > SubprocessResult(id='e9f2d29acb4011ee8957320319d7541c', stdout='hello, world!\n', stderr='', returncode=0, killed_by_token=False)
Expand All @@ -73,6 +85,8 @@ print(result)
You can use strings or [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) objects as positional arguments for `suby`.




## Output

By default, the `stdout` and `stderr` of the subprocess are forwarded to the `stdout` and `stderr` of the current process. The reading from the subprocess is continuous, and the output is every time a full line is read. For continuous reading from `stderr`, a separate thread is created in the main process, so that `stdout` and `stderr` are read independently.
Expand Down

0 comments on commit 423f28f

Please sign in to comment.