Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import threading
from queue import Queue

import mockssh.server


def _handler_run(self):
# Identical to mockssh.server.Handler.run except that the command
# queue is created atomically. Upstream checks `chanid not in
# command_queues` and then assigns a fresh Queue, while paramiko's
# transport thread may concurrently create the queue and put the
# command into it via check_channel_exec_request(); the assignment
# then replaces that queue, the command is lost, and handle_client
# blocks on Queue.get() forever -- the client never receives an
# exit status. mock-ssh-server is unmaintained, so it is patched
# here instead of upstream.
self.transport.start_server(server=self)
while True:
channel = self.transport.accept()
if channel is None:
break
self.command_queues.setdefault(channel.chanid, Queue())
thread = threading.Thread(target=self.handle_client, args=(channel,))
thread.daemon = True
thread.start()


mockssh.server.Handler.run = _handler_run
Loading