Modernize vnpy/rpc to get ready for Python 3
This commit is contained in:
parent
be395abd82
commit
41dee09540
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from vnrpc import RpcClient
|
from vnrpc import RpcClient
|
||||||
@ -17,7 +18,7 @@ class TestClient(RpcClient):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def callback(self, topic, data):
|
def callback(self, topic, data):
|
||||||
"""回调函数实现"""
|
"""回调函数实现"""
|
||||||
print 'client received topic:', topic, ', data:', data
|
print('client received topic:', topic, ', data:', data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -29,5 +30,5 @@ if __name__ == '__main__':
|
|||||||
tc.start()
|
tc.start()
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
print tc.add(1, 3)
|
print(tc.add(1, 3))
|
||||||
sleep(2)
|
sleep(2)
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
|
||||||
from vnrpc import RpcServer
|
from vnrpc import RpcServer
|
||||||
@ -19,7 +20,7 @@ class TestServer(RpcServer):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def add(self, a, b):
|
def add(self, a, b):
|
||||||
"""测试函数"""
|
"""测试函数"""
|
||||||
print 'receiving: %s, %s' % (a,b)
|
print('receiving: %s, %s' % (a,b))
|
||||||
return a + b
|
return a + b
|
||||||
|
|
||||||
|
|
||||||
@ -32,6 +33,6 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
content = 'current server time is %s' % time()
|
content = 'current server time is %s' % time()
|
||||||
print content
|
print(content)
|
||||||
ts.publish('test', content)
|
ts.publish('test', content)
|
||||||
sleep(2)
|
sleep(2)
|
@ -313,5 +313,3 @@ class RemoteException(Exception):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""输出错误信息"""
|
"""输出错误信息"""
|
||||||
return self.__value
|
return self.__value
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user