예제 #1
0
파일: cornado_test.py 프로젝트: bfdy/alpha
    def __handleInput(self, stream):
        async_call = cornado.AsyncCall()
        
        stream.read_bytes(1, async_call.callback)
        data = async_call.wait()
        stream.write(data)

        cornado.getInstance().add_callback(self.__handleInput, stream)
예제 #2
0
    def __handleInput(self, stream):
        async_call = cornado.AsyncCall()

        stream.read_bytes(1, async_call.callback)
        data = async_call.wait()
        stream.write(data)

        cornado.getInstance().add_callback(self.__handleInput, stream)
예제 #3
0
    def sleepLonger(self):
        self.steps.append('2.1')
        cornado.sleep(2)
        self.steps.append('2.2')

        dur = time.time() - self.now
        self.assertTrue(dur > 1 and dur < 3)  #sleep works
        self.assertTrue(self.steps, ['1.1', '2.1', '1.2', '2.2'])
        cornado.getInstance().stop()
예제 #4
0
파일: cornado_test.py 프로젝트: bfdy/alpha
    def sleepLonger(self):
        self.steps.append('2.1')
        cornado.sleep(2)
        self.steps.append('2.2')

        dur = time.time() - self.now
        self.assertTrue(dur > 1 and dur < 3) #sleep works
        self.assertTrue(self.steps, ['1.1', '2.1', '1.2', '2.2'])
        cornado.getInstance().stop()
예제 #5
0
    def start(self):
        s_socks = tornado.netutil.bind_sockets(0, address='127.0.0.1')
        server = EchoServer()
        server.add_sockets(s_socks)
        server_addr = s_socks[0].getsockname()

        client = tornado.iostream.IOStream(
            socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0))

        async_call = cornado.AsyncCall()
        client.connect(server_addr, async_call.callback)
        async_call.wait()

        msg = 'hello'
        client.write(msg)

        async_call = cornado.AsyncCall()
        client.read_bytes(len(msg), async_call.callback)
        self.assertEqual(msg, async_call.wait())

        cornado.getInstance().stop()
예제 #6
0
파일: cornado_test.py 프로젝트: bfdy/alpha
    def start(self):
        s_socks = tornado.netutil.bind_sockets(0, address='127.0.0.1')
        server = EchoServer()
        server.add_sockets(s_socks)
        server_addr = s_socks[0].getsockname()

        client = tornado.iostream.IOStream(
            socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0))
        
        async_call = cornado.AsyncCall()
        client.connect(server_addr, async_call.callback)
        async_call.wait()

        msg = 'hello' 
        client.write(msg)

        async_call = cornado.AsyncCall()
        client.read_bytes(len(msg), async_call.callback)
        self.assertEqual(msg, async_call.wait())

        cornado.getInstance().stop()
예제 #7
0
 def handle_stream(self, stream, address):
     input = functools.partial(self.__handleInput, stream)
     cornado.getInstance().add_callback(input)
예제 #8
0
 def start(self):
     self.now = time.time()
     cornado.getInstance().add_callback(self.sleepLonger)
     cornado.getInstance().add_callback(self.sleepShorter)
예제 #9
0
파일: cornado_test.py 프로젝트: bfdy/alpha
 def handle_stream(self, stream, address):
     input = functools.partial(self.__handleInput, stream)
     cornado.getInstance().add_callback(input)
예제 #10
0
파일: cornado_test.py 프로젝트: bfdy/alpha
 def start(self):
     self.now = time.time()
     cornado.getInstance().add_callback(self.sleepLonger)
     cornado.getInstance().add_callback(self.sleepShorter)