Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
socket read timeout in django request
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 50766cb..b133310 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -38,9 +38,14 @@ class LimitedStream(object):
size = self.remaining
if size == 0:
return b''
- result = self.stream.read(size)
- self.remaining -= len(result)
- return result
+ self.stream._sock.settimeout(10)
+ try:
+ result = self.stream.read(size)
+ except http.UnreadablePostError:
+ raise Exception('Some exception')
+ else:
+ self.remaining -= len(result)
+ return result
def read(self, size=None):
if size is None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment