def get_pid(self) -> typing.Optional[int]: pid_path = self._path.joinpath('pid') # get pid stdout_list: typing.List[bytes] = [] if connection.run_ssh(self._ssh_client, [ 'cat', str(pid_path), ], iteration.empty_in(), iteration.collect_out(stdout_list), iteration.ignore_out())(): return None pid = int(b''.join(stdout_list).decode().strip()) # find process if connection.run_ssh(self._ssh_client, [ 'kill', '-0', str(pid), ], iteration.empty_in(), iteration.empty_out(), iteration.ignore_out())(): return None return pid
def test_iteration_adhoc_out() -> None: gen_out = iteration.empty_out() next(gen_out) gen_out.send(b'') assert not list(gen_out) gen_out = iteration.empty_out() next(gen_out) catched_error = False try: gen_out.send(b'1') except RuntimeError: catched_error = True assert catched_error gen_out = iteration.ignore_out() next(gen_out) gen_out.send(b'1') gen_out.send(b'2') gen_out.send(b'3') gen_out.send(b'') assert not list(gen_out) stdout_list: typing.List[bytes] = [] gen_out = iteration.collect_out(stdout_list) next(gen_out) gen_out.send(b'1') gen_out.send(b'2') gen_out.send(b'3') gen_out.send(b'') assert stdout_list == [b'1', b'2', b'3'] assert not list(gen_out)
def run() -> None: connection.run_process( [clickhouse.binary_file(), 'client'], iteration.given_in([b'select number from numbers(1000000)']), iteration.ignore_out(), iteration.empty_out() )()
def run() -> None: connection.run_http( 'localhost', 8123, '/', iteration.given_in([b'select number from numbers(1000000)']), iteration.ignore_out(), iteration.empty_out() )()
def test_iteration_ignore_out() -> None: gen_out = iteration.ignore_out() next(gen_out) gen_out.send(b'1') gen_out.send(b'2') gen_out.send(b'3') gen_out.send(b'') assert not list(gen_out)