Skip to content

Commit 52e4027

Browse files
author
Martin Hanzalek
committed
added:
- parsing of shell command into a list in suprocess example - usage of RLock() as a context manager - how to log exceptions in loguru example
1 parent 6ba48df commit 52e4027

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,8 @@ import os
11791179

11801180
### Subprocess
11811181
```python
1182-
>>> import subprocess
1183-
>>> a = subprocess.run(['ls', '-a'], stdout=subprocess.PIPE)
1182+
>>> import subprocess, shlex
1183+
>>> a = subprocess.run(shlex.split('ls -a'), stdout=subprocess.PIPE)
11841184
>>> a.stdout
11851185
b'.\n..\nfile1.txt\nfile2.txt\n'
11861186
>>> a.returncode
@@ -1421,6 +1421,12 @@ lock.acquire()
14211421
...
14221422
lock.release()
14231423
```
1424+
or
1425+
```python
1426+
lock = RLock()
1427+
with lock:
1428+
...
1429+
```
14241430

14251431

14261432
Introspection
@@ -1701,6 +1707,13 @@ logger.<level>('A logging message')
17011707
```
17021708
* **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.**
17031709

1710+
```python
1711+
try:
1712+
...
1713+
except Exception as e:
1714+
logger.exception('An error happened', e)
1715+
```
1716+
17041717
### Rotation
17051718
**Parameter that sets a condition when a new log file is created.**
17061719
```python

0 commit comments

Comments
 (0)