Skip to content

Commit

Permalink
Remove python socket timeout
Browse files Browse the repository at this point in the history
Timeout is already set in HttpClient. The reason for removal is issue
with gunicorn and gevent as described here
benoitc/gunicorn#1616
  • Loading branch information
Josip Sokcevic committed Apr 27, 2018
1 parent 0293c36 commit 0737ecf
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions lib/py/src/transport/THttpClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from io import BytesIO
import os
import socket
import ssl
import sys
import warnings
Expand Down Expand Up @@ -128,9 +127,6 @@ def isOpen(self):
return self.__http is not None

def setTimeout(self, ms):
if not hasattr(socket, 'getdefaulttimeout'):
raise NotImplementedError

if ms is None:
self.__timeout = None
else:
Expand All @@ -145,17 +141,6 @@ def read(self, sz):
def write(self, buf):
self.__wbuf.write(buf)

def __withTimeout(f):
def _f(*args, **kwargs):
orig_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(args[0].__timeout)
try:
result = f(*args, **kwargs)
finally:
socket.setdefaulttimeout(orig_timeout)
return result
return _f

def flush(self):
if self.isOpen():
self.close()
Expand Down Expand Up @@ -200,7 +185,3 @@ def flush(self):
self.code = self.__http_response.status
self.message = self.__http_response.reason
self.headers = self.__http_response.msg

# Decorate if we know how to timeout
if hasattr(socket, 'getdefaulttimeout'):
flush = __withTimeout(flush)

0 comments on commit 0737ecf

Please # to comment.