Damian Johnson dc051cee91 Catch BrokenPipeError when closing unix sockets
I spent a few hours investigating the root cause but no luck. When closing a
unix socket that has been terminated by the other end our closed_wait() method
raises a BrokenPipeError. In the following test this causes us to fail to
reconnect the socket (because reconnection first closes us).

This only happens with a ControlSocket (ie. our RUN_SOCKET test target).

  ======================================================================
  ERROR: test_pre_disconnected_query
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/home/atagar/Desktop/stem/test/require.py", line 75, in wrapped
      return func(self, *args, **kwargs)
    File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 701, in wrapper
      result = loop.run_until_complete(func(*args, **kwargs))
    File "/home/atagar/Python-3.7.0/Lib/asyncio/base_events.py", line 568, in run_until_complete
      return future.result()
    File "/home/atagar/Desktop/stem/test/integ/response/protocolinfo.py", line 122, in test_pre_disconnected_query
      self.assert_matches_test_config(protocolinfo_response)
    File "/home/atagar/Desktop/stem/stem/socket.py", line 293, in __aexit__
      await self.close()
    File "/home/atagar/Desktop/stem/stem/socket.py", line 203, in close
      await self._close_wo_send_lock()
    File "/home/atagar/Desktop/stem/stem/socket.py", line 215, in _close_wo_send_lock
      await self._writer.wait_closed()
    File "/home/atagar/Python-3.7.0/Lib/asyncio/streams.py", line 323, in wait_closed
      await self._protocol._closed
    File "/home/atagar/Desktop/stem/test/integ/response/protocolinfo.py", line 121, in test_pre_disconnected_query
      protocolinfo_response = await stem.connection.get_protocolinfo(control_socket)
    File "/home/atagar/Desktop/stem/stem/connection.py", line 1077, in get_protocolinfo
      await controller.connect()
    File "/home/atagar/Desktop/stem/stem/socket.py", line 181, in connect
      await self._close_wo_send_lock()
    File "/home/atagar/Desktop/stem/stem/socket.py", line 215, in _close_wo_send_lock
      await self._writer.wait_closed()
    File "/home/atagar/Python-3.7.0/Lib/asyncio/streams.py", line 323, in wait_closed
      await self._protocol._closed
    File "/home/atagar/Python-3.7.0/Lib/asyncio/selector_events.py", line 868, in write
      n = self._sock.send(data)
  BrokenPipeError: [Errno 32] Broken pipe
2020-07-31 17:34:29 -07:00
2020-07-29 16:56:52 -07:00
2019-08-17 14:37:10 -07:00
2020-07-18 17:51:39 -07:00
2011-10-27 19:43:45 -07:00
2018-08-05 13:02:55 -07:00
2020-07-14 17:31:45 -07:00
2017-02-01 08:37:13 -08:00

Stem (Python Tor Library)

Stem is a Python controller library for Tor. With it you can use Tor's control protocol to script against the Tor process, or build things such as Nyx.

Documentation and tutorials available at stem.torproject.org.

Description
Python controller library for Tor
Readme 10 MiB
Languages
Python 97.5%
Roff 2.5%