question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection.sudo() sometimes raises ThreadException/OSError instead of AuthFailure

See original GitHub issue
invoke.exceptions.ThreadException: 
Saw 1 exceptions within threads (OSError):


Thread args: {'kwargs': {'buffer_': ['[sudo] password: '],
            'hide': False,
            'output': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>},
 'target': <bound method Runner.handle_stderr of <fabric.runners.Remote object at 0x7f066e63a9e8>>}

Traceback (most recent call last):

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/util.py", line 233, in run
    super(ExceptionHandlingThread, self).run()

  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 750, in handle_stderr
    buffer_, hide, output, reader=self.read_proc_stderr

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 717, in _handle_output
    self.respond(buffer_)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 884, in respond
    self.write_proc_stdin(response)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/invoke/runners.py", line 960, in write_proc_stdin
    self._write_proc_stdin(data.encode(self.encoding))

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/fabric/runners.py", line 67, in _write_proc_stdin
    return self.channel.sendall(data)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 846, in sendall
    sent = self.send(s)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 801, in send
    return self._send(s, m)

  File "/home/amezin/test/.venv/lib/python3.6/site-packages/paramiko/channel.py", line 1198, in _send
    raise socket.error("Socket is closed")

OSError: Socket is closed

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
matt-haydencommented, Apr 9, 2020

I think what you might be seeing is a different error: I don’t think it’s getting to the sudo auth phase. I’m seeing this on Python 2.7 but only when stdin is redirected from /dev/null. Maybe try again with pty=True?

2reactions
luke-goddardcommented, May 10, 2020

@matt-hayden After hours of debugging you just saved me from a mental breakdown. I would also like to add that I only got this error while using multiprocessing.Process even if it’s just one process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found