打开python服务器
在这里,我有一些我需要工作的抽象代码。
>>> s0 = Server(port='5000', handle=print)
>>> s0.stop()
>>> # Starting a second server with another port seems OK.
>>> s1 = Server(port='5001', handle=print)
>>> s1.stop()
>>> # This will raise Exception, because port '5000' is still busy by a first server(s0 object).
>>> # I have to exit python process, to release port.
>>> # P.S. deleting an object does not change anything.
>>> s2 = Server(port='5000', handle=print)
我尝试了烧瓶。 我尝试了SumplexmlrpcServer: ?
即使没有引起异常,(S2对象)不接受请求,它们无处不在,不返回状态或任何东西。
例如,如何在端口“ 5000”上创建服务器,关闭此服务器并在需要时再次创建它。 Python有可能吗?
Here I have some abstract code that I need to work.
>>> s0 = Server(port='5000', handle=print)
>>> s0.stop()
>>> # Starting a second server with another port seems OK.
>>> s1 = Server(port='5001', handle=print)
>>> s1.stop()
>>> # This will raise Exception, because port '5000' is still busy by a first server(s0 object).
>>> # I have to exit python process, to release port.
>>> # P.S. deleting an object does not change anything.
>>> s2 = Server(port='5000', handle=print)
I've tried Flask.
I've tried SimpleXMLRPCServer:
How to stop BaseHTTPServer.serve_forever() in a BaseHTTPRequestHandler subclass?
Even if it is not raising Exception, the (s2 object) does not accept requests, they are going nowhere, not returning a status or anything.
How can I create a server on port '5000' for example, close this server and create it again when needed. Is it possible with python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论