Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomly disconnecting using Textual #2292

Open
charles-001 opened this issue Jan 11, 2024 · 0 comments
Open

Randomly disconnecting using Textual #2292

charles-001 opened this issue Jan 11, 2024 · 0 comments

Comments

@charles-001
Copy link

charles-001 commented Jan 11, 2024

Hello,

I'm using the latest version of Fabric with Textual (a TUI) and am experiencing random disconnections when clicking around in the UI I created. I tested the code below by itself and did not experience any disconnecting, but when using it with Textual is what starts the issue. Any help here would be appreciated as I've tried paramiko by itself and asyncssh without any issue but I'd prefer to use Fabric since my app is already built for it.

Test code:

connection = Connection(host=tab.machine.host_name, connect_timeout=5)
while True:
    command = "echo 'hello'"
    result = connection.run(command)
    tab.logger.info(result.stdout)

    sleep(1)

The error I get is:

ThreadException:
Saw 1 exceptions within threads (OSError):

Thread args: {'kwargs': {'echo': None,
            'input_': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
            'output': <textual.app._PrintCapture object at 0x103a79750>},
 'target': <bound method Runner.handle_stdin of <fabric.runners.Remote object at 0x104095350>>}

Traceback (most recent call last):

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/invoke/util.py", line 211, in run
    super().run()

  File "/Users/cthompson/.pyenv/versions/3.11.4/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/invoke/runners.py", line 877, in handle_stdin
    self.write_proc_stdin(data)

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/invoke/runners.py", line 1017, in write_proc_stdin
    self._write_proc_stdin(data.encode(self.encoding))

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/fabric/runners.py", line 92, in _write_proc_stdin
    return self.channel.sendall(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/paramiko/channel.py", line 844, in sendall
    sent = self.send(s)
           ^^^^^^^^^^^^

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/paramiko/channel.py", line 799, in send
    return self._send(s, m)
           ^^^^^^^^^^^^^^^^

  File "/Users/cthompson/Library/Caches/pypoetry/virtualenvs/app-mQ1EG55C-py3.11/lib/python3.11/site-packages/paramiko/channel.py", line 1196, in _send
    raise socket.error("Socket is closed")

OSError: Socket is closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant