πŸ› Follow up to recent changes on to channel.recv_exit_status() lines

On e831ee037c we have removed all traces
of initial buffering of stdout in that function. Let's see if this
middle ground, in which we advance the file pointer by one byte (and
thus pull in some cache/extra meat to be consumed on stdout), but only
one byte, is enough not to hang on those crazy, different scenarios.

This fixes pristine Windows boxes detection again.
This commit is contained in:
Gustavo Lima Chaves 2021-04-27 15:40:22 -07:00 ΠΊΠΎΠΌΠΌΠΈΡ‚ ΠΏΡ€ΠΎΠΈΠ·Π²Ρ‘Π» Chi Song
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ 33a7cea454
ΠšΠΎΠΌΠΌΠΈΡ‚ ea7bf7bb86
1 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 8 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 1 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -154,8 +154,15 @@ def try_connect(connection_info: ConnectionInfo) -> Any:
banner_timeout=10,
)
stdin, stdout, _ = paramiko_client.exec_command("cmd\n")
# flush commands and prevent more writes
# Flush commands and prevent more writes
stdin.flush()
# Give it time to read/buffer something, otherwise reads on stdout
# on calling contexts have been seen having empty strings from
# stdout, on Windows. There is no moving back, but losing one byte
# is not an issue for the function's intent
_ = stdout.channel.recv(1)
stdin.channel.shutdown_write()
paramiko_client.close()