2012-09-01 85 views
1

在我的應用程序中,我在頁面加載時使用Jquery發送Ajax get請求。如果通話時間過長,用戶可能會在標準瀏覽會話期間離開初始頁面。最終,這個ajax調用完成並且發回響應。問題是,到了這個時候用戶已經離開了這個頁面,沒有人再聽任何迴應了。發生這種情況時,我的日誌中會出現此異常。在長時間運行AJAX調用期間導航離開頁面時防止出現Django異常

---------------------------------------- 
Exception happened during processing of request from ('98.x.x.x', 36495) 
Traceback (most recent call last): 
    File "M:\Python2.7\App\lib\SocketServer.py", line 582, in process_request_thread 
    self.finish_request(request, client_address) 
    File "M:\Python2.7\App\lib\SocketServer.py", line 323, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
    File "M:\Python2.7\App\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__ 
    super(WSGIRequestHandler, self).__init__(*args, **kwargs) 
    File "M:\Python2.7\App\lib\SocketServer.py", line 640, in __init__ 
    self.finish() 
    File "M:\Python2.7\App\lib\SocketServer.py", line 693, in finish 
    self.wfile.flush() 
    File "M:\Python2.7\App\lib\socket.py", line 303, in flush 
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
error: [Errno 10053] An established connection was aborted by the software in your host machine 
---------------------------------------- 

我該如何防止這種情況發生?

例外中列出的文件都不是我的代碼。

回答

0

只有當您使用django開發服務器時,纔會發生這種情況,該服務器會嘗試在控制檯上記錄異常。

但是,與其他網絡服務器(如Apache),你會得到類似的例外,但可能不那麼描述。

相關問題