From: David Reiss Date: Mon, 18 Feb 2008 02:11:48 +0000 (+0000) Subject: Implement testAsync for python tests X-Git-Tag: 0.2.0~987 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=db893b617f3cd4e7170ced145d75a8a16d7abc97;p=common%2Fthrift.git Implement testAsync for python tests git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665485 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/py/TestClient.py b/test/py/TestClient.py index ab2cba85..d7b65b74 100755 --- a/test/py/TestClient.py +++ b/test/py/TestClient.py @@ -86,6 +86,13 @@ class AbstractTest(unittest.TestCase): self.assertEqual(x.errorCode, 1001) self.assertEqual(x.message, 'Xception') + def testAsync(self): + start = time.time() + self.client.testAsync(2) + end = time.time() + self.assertTrue(end - start < 0.2, + "async sleep took %f sec" % (end - start)) + class NormalBinaryTest(AbstractTest): protocol_factory = TBinaryProtocol.TBinaryProtocolFactory() diff --git a/test/py/TestServer.py b/test/py/TestServer.py index 94a81c05..4c6cb8a3 100755 --- a/test/py/TestServer.py +++ b/test/py/TestServer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, glob +import sys, glob, time sys.path.insert(0, './gen-py') sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) @@ -52,6 +52,11 @@ class TestHandler: x.message = str raise x + def testAsync(self, seconds): + print 'testAsync(%d) => sleeping...' % seconds + time.sleep(seconds) + print 'done sleeping' + handler = TestHandler() processor = ThriftTest.Processor(handler) transport = TSocket.TServerSocket(9090)