Browse Source

qt TorDetector: close socket

ResourceWarning below is shown when running python3 with "-X dev":

...\electrum\electrum\gui\qt\network_dialog.py:457: ResourceWarning: unclosed <socket.socket fd=3276, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 55693), raddr=('127.0.0.1', 9050)>
  if TorDetector.is_tor_port(net_addr):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
patch-4
SomberNight 4 years ago
parent
commit
52f4189176
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/qt/network_dialog.py

2
electrum/gui/qt/network_dialog.py

@ -464,7 +464,7 @@ class TorDetector(QThread):
@staticmethod
def is_tor_port(net_addr: Tuple[str, int]) -> bool:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(0.1)
s.connect(net_addr)
# Tor responds uniquely to HTTP-like requests

Loading…
Cancel
Save