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