[
https://issues.apache.org/jira/browse/THRIFT-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466594#comment-16466594
]
ASF GitHub Bot commented on THRIFT-4561:
----------------------------------------
jeking3 closed pull request #1550: THRIFT-4561: Remove python socket timeout
URL: https://github.com/apache/thrift/pull/1550
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/lib/py/src/transport/THttpClient.py
b/lib/py/src/transport/THttpClient.py
index 60ff226a90..37b0a4d8dd 100644
--- a/lib/py/src/transport/THttpClient.py
+++ b/lib/py/src/transport/THttpClient.py
@@ -19,7 +19,6 @@
from io import BytesIO
import os
-import socket
import ssl
import sys
import warnings
@@ -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:
@@ -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()
@@ -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)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Python: cleanup socket timeout settings
> ---------------------------------------
>
> Key: THRIFT-4561
> URL: https://issues.apache.org/jira/browse/THRIFT-4561
> Project: Thrift
> Issue Type: Task
> Components: Python - Library
> Reporter: Josip Sokcevic
> Priority: Trivial
>
> Setting default socket timeout can lead to side effects with latest version
> of gunicorn:
> [https://github.com/benoitc/gunicorn/issues/880]
> [https://github.com/benoitc/gunicorn/pull/1616]
> Since timeout is set in HttpClient, there's no longer need to set socket
> default timeout
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)