Add timeout to Python class

This commit is contained in:
Grégory Soutadé 2016-02-04 20:39:50 +01:00
parent 9b0bdae64e
commit a10ce76381
1 changed files with 2 additions and 0 deletions

View File

@ -36,6 +36,8 @@ class IPToGeo(object):
def _create_socket(self):
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if not self._timeout is None:
self._socket.settimeout(self._timeout)
self._socket.connect((self._remote_addr, self._remote_port))
def _create_request(self, int_ip):