]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
cephadm: refactor call() using asyncio.asyncio.StreamReader 39043/head
authorKefu Chai <kchai@redhat.com>
Sun, 24 Jan 2021 06:58:51 +0000 (14:58 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 26 Jan 2021 09:48:32 +0000 (17:48 +0800)
commit30070be24860c2dfc0d27c79b0958d6c09316d87
treef7a6e41e553e310d71acbd533858c8c1242efa20
parent24e858ec31d5962b5ed51b93ff782de52350d22c
cephadm: refactor call() using asyncio.asyncio.StreamReader

simpler this way, also fix a couple issues:

* create a child watcher explicitly, see
  https://bugs.python.org/issue35621
* use StringIO for collecting outputs for better performance,
  instead of appending the lines to an existing str
* catch ValueError when reading from the stream reader,
  because StreamReader.readline() could raise ValueError when
  it reaches the buffer limit while looking for a separator.
  in this case, we should try again, in hope that the spawned
  process can feed the reader with more data which contains
  the separator (i.e., b'\n').
* backport ThreadedChildWatcher from Python 3.8 so we can
  run create_subprocess_exec() in non-main threads.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/cephadm/cephadm