THRIFT-637. python: Fix mixing of oneway and regular requests in TNonblockingServer
authorTodd Lipcon <todd@apache.org>
Thu, 3 Dec 2009 01:18:44 +0000 (01:18 +0000)
committerTodd Lipcon <todd@apache.org>
Thu, 3 Dec 2009 01:18:44 +0000 (01:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@886646 13f79535-47bb-0310-9956-ffa450edef68

lib/py/src/server/TNonblockingServer.py
test/py/TestClient.py

index deec708..ea348a0 100644 (file)
@@ -178,11 +178,12 @@ class Connection:
             self.wake_up()
             return
         self.len = ''
-        self.message = struct.pack('!i', len(message)) + message
         if len(message) == 0:
             # it was a oneway request, do not write answer
+            self.message = ''
             self.status = WAIT_LEN
         else:
+            self.message = struct.pack('!i', len(message)) + message
             self.status = SEND_ANSWER
         self.wake_up()
 
index 64e5e87..0a38b03 100755 (executable)
@@ -129,6 +129,10 @@ class AbstractTest(unittest.TestCase):
     end = time.time()
     self.assertTrue(end - start < 0.2,
                     "oneway sleep took %f sec" % (end - start))
+  
+  def testOnewayThenNormal(self):
+    self.client.testOneway(0.5)
+    self.assertEqual(self.client.testString('Python'), 'Python')
 
 class NormalBinaryTest(AbstractTest):
   protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()