[英]How to manually close connection in BaseHTTPServer?
我有一個將請求發送到HTTP服務器的腳本。
HTTP服務器腳本(代碼段):
...
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(sa):
pdict = cgi.parse_header(sa.headers.getheader('referer'))
q = pdict[0]
q = urllib.unquote(q)
if q == "enternetixplorer" # basically just ignore this, doesn't have to do with the question
sa.wfile.write("blah blah blah")
# now restart server
httpd.server_close()
python = sys.executable
os.execl(python, python, * sys.argv)
...
發送回“等等等等”,但是連接似乎沒有關閉,並且我的腳本一直在等待,直到我中止服務器。 (我的想法是,在計算“ do_GET()”的最后一部分時,BaseHTTPServer會自動關閉連接,但是我通過重新啟動腳本來防止這種情況。)
如果我是對的,如何關閉連接? 如果沒有,那可能是什么問題?
編輯:服務器腳本必須重新啟動整個程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.