我想做的是,而不是硬编码5中测试.py. 我想为不同的测试用例传递不同的值。有可能吗?你知道吗
修改前:上面例子的输出是
./my_program
created script
running
result=10
我的想法是将xmlrpcserver添加到测试.py接受输入。在我改变之后测试.py如下所示,重新生成并运行的线程由xmlrpc服务器持有。退出时,将抛出一个错误,如下所示。你知道吗
有什么建议吗?你知道吗
./my_program
Listening on port 8000 ...
Hello
127.0.0.1 - - [18/Oct/2018 15:06:34] "POST /RPC2 HTTP/1.1" 200 -
^Cterminate called after throwing an instance of 'boost::python::error_already_set'
Aborted (core dumped)
修改的测试.py你知道吗
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
from SimpleXMLRPCServer import SimpleXMLRPCServer
class Script(object):
def __init__(self, ifc):
print 'created script'
self.ifc = ifc
def run(self):
print 'running'
self.ifc.execute(5)
self.startRPC()
def result(self, i):
print 'result={}'.format(i)
def startRPC(self):
server = SimpleXMLRPCServer(("", 8000), allow_none=True)
print ("Listening on port 8000 ...")
server.register_instance(self)
server.serve_forever()
我变了测试.py如上所述。 我还将try-and-catch添加到main()
int main(){
try{
....
} catch (const bp::error_already_set&)
{
PyErr_Print();
return 1;
}
}
现在输出为:
./my_program
created script
running
result=10
Listening on port 8000 ...
^CTraceback (most recent call last):
File "test.py", line 16, in run
self.startRPC()
File "test.py", line 31, in startRPC
server.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 236, in serve_forever
poll_interval)
File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry
return func(*args)
KeyboardInterrupt
事实上,我注意到没有更多的核心转储。是因为捕获了异常吗? 谢谢你的帮助。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐