Buffer capacity is always 0 if the buffer is allocated externally. Also, we don't want to allocate unneccessary extra space if only parts of a buffer a used (e.g. when slicing).
By using read_line, we make stderr similar to stdout.
Moreover, we can replicate the functionality in stdout in stderr and retrieve
the full traceback for python nodes. This way, we can print python errors in the daemon logs
without having to look at the log files.
The newline between each line in the logs seems to have been removed.
I have readded it, so that logs look like this
```bash
─────┬───────────────────────────────────────────────────────────────
│ Logs from webcam.
─────┬───────────────────────────────────────────────────────────────
1 │ Traceback (most recent call last):
2 │ File "<string>", line 1, in <module>
3 │ RuntimeError: Dora Runtime raised an error.
4 │
5 │ Caused by:
6 │ 0: main task failed
7 │ 1: failed to init an operator
8 │ 2: failed to init python operator
9 │ 3: Traceback (most recent call last):
10 │ File "/home/peter/abc_project/webcam.py", line 7, in <module>
11 │ import cv2
12 │
13 │
14 │ ModuleNotFoundError: No module named 'cv2'
15 │
16 │ Location:
17 │ binaries/runtime/src/operator/python.rs:28:9
─────┴───────────────────────────────────────────────────────────
```
instead of
```bash
─────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Logs from webcam.
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ Exception ignored in: <function Operator.__del__ at 0x7fa0339ff7f0>Traceback (most recent call last): File "/home/peter/abc_project/webcam.py", line 53, in __del__ self.video_capture.release()AttributeError: 'Operator' object has no attribute 'video_capture'Traceback (most recent call last): File "<string>", line 1, in <module>RuntimeError: Dora Runtime raised an error.Caused by: 0: main task failed 1: failed to init an operator 2: failed to init python operator 3: Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/peter/abc_project/webcam.py", line 22, in __init__ self.video_capture = cv2.VideoCapture(0) AttributeError: module 'cv2' has no attribute 'VideoCapture'Location: binaries/runtime/src/operator/python.rs:28:9
─────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
There is a current vulnerability (low severity) and the crate appears to be unmaintained. Since Rust 1.70, we should be able to use the new `IsTerminal` trait of the standard library instead.
The dataflow might be finished already when `dora stop` is invoked, which caused an error previously. This commit changes this behavior to return the dataflow result instead in this case.
The name generator uses a thread-local random number generator internally, which makes it `!Send`. So we should not keep it across await points because our `multiple_daemons` example needs to spawn it in the tokio runtime, which requires `Send`.