THRIFT-3390 Tornado server should gracefully handle closed connections
Clidnt: Python.Tornado
Patch: Christian Verkerk <christian@tubularlabs.com>
This closes #654
diff --git a/lib/py/src/TTornado.py b/lib/py/src/TTornado.py
index ef3e0f2..65795ab 100644
--- a/lib/py/src/TTornado.py
+++ b/lib/py/src/TTornado.py
@@ -171,7 +171,13 @@
try:
while not trans.stream.closed():
- frame = yield trans.readFrame()
+ try:
+ frame = yield trans.readFrame()
+ except TTransportException as e:
+ if e.type == TTransportException.END_OF_FILE:
+ break
+ else:
+ raise
tr = TMemoryBuffer(frame)
iprot = self._iprot_factory.getProtocol(tr)
yield self._processor.process(iprot, oprot)