如何结束while True循环,我希望循环在标记的位置结束,但是我尝试了break和{},两者都没有结束循环。它只是让脚本继续运行,而它基本上就停留在那里,什么也不做。class MyHandler(BaseHTTPRequestHandler):
def log_message(self, format, *args):
return
def do_GET(self):
if self.path.startswith(“/checkTransfer”):
qs = {}
path = self.path
if ‘?’ in self.path:
qs = parse_qs(urlparse(self.path).query)
print “Received Transfer Check request for transfer id: ” + qs[“transferID”][0]
while True:
if checkProgress(qs[“transferID”][0]) == 1:
self.send_response(200)
self.send_header(‘Content-type’, ‘text/json’)
self.end_headers()
self.wfile.write(‘{“status” : 1}’)
print “Transfer Completed! Checking for downloads”
******* break; *******
******* ^ This is where I need to end the loop *******
elif checkProgress(qs[“transferID”][0]) == 0:
self.send_response(200)
self.send_header(‘Content-type’, ‘text/json’)
self.end_headers()
self.wfile.write(‘{“status” : 0}’)
print “Incomplete Transfer, Waiting…”
time.sleep(3)
elif checkProgress(qs[“transferID”][0]) == 2:
self.send_response(200)
self.send_header(‘Content-type’, ‘text/json’)
self.end_headers()
print “Could Not Find Transfer, Could Be Removed”
self.wfile.write(‘{“status” : 2}’)
break;