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は自動的に接続を閉じると思いますが、スクリプトを再起動することでこれを防ぎます。)
私が正しければ、どうすれば接続を閉じることができますか? そうでない場合、他に何が問題になっている可能性がありますか?
編集:サーバースクリプトはプログラム全体を再起動する必要があります。