[英]Python BaseHTTPServer stops rest of script
I am using BaseHTTPServer to serve a simple variable, the problem is that the rest after server.serve_forever()
is not executing. 我正在使用BaseHTTPServer提供一个简单的变量,问题是
server.serve_forever()
之后的其余部分没有执行。
It does not seem that BaseHTTPServer is forking? 看来BaseHTTPServer不是在派生吗?
How can i get around this problem? 我该如何解决这个问题?
The variable (http output) BaseHTTPServer is serving is continiously updated by the other part of the script. 脚本的另一部分不断更新BaseHTTPServer服务的变量(http输出)。
Here is a pastebin: http://pastebin.com/v4xEuHBs 这是一个pastebin: http : //pastebin.com/v4xEuHBs
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import SocketServer
import os
def main():
try:
startserver(self)
def startserver(self):
newpid = os.fork()
if newpid == 0:
server = HTTPServer(('',8080), ThreadingHTTPServer)
server.serve_forever()
class ThreadingHTTPServer(SocketServer.ThreadingMixIn,BaseHTTPRequestHandler):
def do_GET(self):
self.loop = loop
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write('hello, world')
return
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.