我使用多处理 python 功能使用 Fork(process) 方法解决了问题。我定义了应用 Flask 然后运行来处理
def info(title):
print(title)
print('module name:', __name__)
if hasattr(os, 'getppid'): # only available on Unix
print('parent process:', os.getppid())
print('process id:', os.getpid())
def startServer(inDebug, port):
print "Starting Main Mock Server"
app.run(debug=inDebug, port=port)
def startProxyServer(inDebug, port):
print "Starting JSONP Mock Server Proxy"
appJsonp.run(debug=inDebug, port=jsonpPort)
if __name__ == '__main__':
info('Main Line Starting')
p = mp.Process(target=startServer, args=(False, port))
p.deamon = True
p.start()
p1 = mp.Process(target=startProxyServer, args=(False, port))
p1.deamon = True
p1.start()
p.join()
p1.join()