Tidy if/else branch on _recreate_socket

This commit is contained in:
Lonami Exo 2017-05-30 11:42:14 +02:00
parent 2399b7e55e
commit d321096714

View File

@ -20,15 +20,13 @@ class TcpClient:
self._lock = Lock() self._lock = Lock()
def _recreate_socket(self): def _recreate_socket(self):
self._socket = None if self._proxy is None:
if self._proxy is not None: self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
else:
import socks import socks
self._socket = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM) self._socket = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.set_proxy(*self._proxy) self._socket.set_proxy(*self._proxy)
if not self._socket:
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def connect(self, ip, port): def connect(self, ip, port):
"""Connects to the specified IP and port number""" """Connects to the specified IP and port number"""
if not self.connected: if not self.connected: