Modernize vnpy/rpc to get ready for Python 3

This commit is contained in:
cclauss 2018-04-13 10:17:28 +02:00
parent be395abd82
commit 41dee09540
3 changed files with 72 additions and 72 deletions

View File

@ -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)

View File

@ -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)

View File

@ -313,5 +313,3 @@ class RemoteException(Exception):
def __str__(self):
"""输出错误信息"""
return self.__value