我试图找出如何在运行“.serve.forever()方法后在后台运行我重载的自定义BaseHTTPServer实例.
通常,当您运行该方法时,执行将挂起,直到您执行键盘中断,但我希望它在后台继续执行脚本时提供请求.请帮忙!
最佳答案 您可以在另一个线程中启动服务器:
https://docs.python.org/2/library/thread.html
所以类似于:
def start_server():
# Setup stuff here...
server.serve_forever()
# start the server in a background thread
thread.start_new_thread(start_server)
print('The server is running but my script is still executing!')