]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
cephadm: refactor call() using asyncio.asyncio.StreamReader
authorKefu Chai <kchai@redhat.com>
Sun, 24 Jan 2021 06:58:51 +0000 (14:58 +0800)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 29 Jan 2021 12:42:38 +0000 (13:42 +0100)
commitebd91efdad378ec9a6c00b0febc24d001b454411
tree95b7529a8c375ef5260af7a124ce537796926060
parent7418a94e81321403711f8ec572ecaf42cd3627e7
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>
(cherry picked from commit 30070be24860c2dfc0d27c79b0958d6c09316d87)
src/cephadm/cephadm