[apt-proxy-devel] r680 - trunk/apt_proxy
Chris Halls
halls at alioth.debian.org
Tue Feb 5 19:01:58 UTC 2008
Author: halls
Date: Tue Feb 5 19:01:58 2008
New Revision: 680
Log:
Add handling for some unknown exceptions
Modified:
trunk/apt_proxy/cache.py
trunk/apt_proxy/clients.py
trunk/apt_proxy/fetchers.py
Modified: trunk/apt_proxy/cache.py
==============================================================================
--- trunk/apt_proxy/cache.py (original)
+++ trunk/apt_proxy/cache.py Tue Feb 5 19:01:58 2008
@@ -173,6 +173,7 @@
self.backend.stop_download(self, request)
if self.fetcher is not None:
self.fetcher.cancel_download()
+ self.fetcher = None
self.state = self.STATE_FAILED
elif (self.state == self.STATE_DOWNLOAD and
not self.factory.config.complete_clientless_downloads ):
@@ -185,6 +186,7 @@
" to continue)",
'cacheEntry')
self.fetcher.cancel_download()
+ self.fetcher = None
self.state = self.STATE_FAILED
if self.streamfile is not None:
Modified: trunk/apt_proxy/clients.py
==============================================================================
--- trunk/apt_proxy/clients.py (original)
+++ trunk/apt_proxy/clients.py Tue Feb 5 19:01:58 2008
@@ -125,11 +125,18 @@
try:
self.cacheEntry.add_request(self)
except Exception, e:
- log.err('unknown error adding request %s - %s' % (self, e), 'HttpRequestClient')
- self.finishCode(http.INTERNAL_SERVER_ERROR, 'Internal error')
- self.transport.loseConnection()
+ self.internal_error('adding request %s - %s' % (self, e))
raise
+ def internal_error(self, message):
+ """
+ An unknown error occured - tell client and close connection
+ """
+ log.err('unknown error: %s' % (message), 'HttpRequestClient')
+ self.finishCode(http.INTERNAL_SERVER_ERROR, 'Internal error')
+ if self.transport is not None:
+ self.transport.loseConnection()
+
def clean_path(self, uri):
# Clean up URL given
scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
Modified: trunk/apt_proxy/fetchers.py
==============================================================================
--- trunk/apt_proxy/fetchers.py (original)
+++ trunk/apt_proxy/fetchers.py Tue Feb 5 19:01:58 2008
@@ -358,17 +358,22 @@
if self.finished:
return
log.debug('handleResponse status=%s' % (self.http_status), 'HttpFetcher')
- if self.http_status == http.NOT_MODIFIED:
- log.debug("Backend server reported file is not modified: " + self.uri,'HttpFetcher')
- self.fetcher.up_to_date()
- elif self.http_status == http.NOT_FOUND:
- log.debug("Not found on backend server",'HttpFetcher')
- self.fetcher.file_not_found()
- elif self.http_status == http.OK:
- self.download_complete()
- else:
- log.debug("Unknown status code: %s" % (self.http_status),'HttpFetcher')
- self.fetcher.fetcher_internal_error("Unknown status code: %s" % (self.http_status))
+ try:
+ if self.http_status == http.NOT_MODIFIED:
+ log.debug("Backend server reported file is not modified: " + self.uri,'HttpFetcher')
+ self.fetcher.up_to_date()
+ elif self.http_status == http.NOT_FOUND:
+ log.debug("Not found on backend server",'HttpFetcher')
+ self.fetcher.file_not_found()
+ elif self.http_status == http.OK:
+ self.download_complete()
+ else:
+ log.debug("Unknown status code: %s" % (self.http_status),'HttpFetcher')
+ self.fetcher.fetcher_internal_error("Unknown status code: %s" % (self.http_status))
+ except Exception, e:
+ self.fetcher.fetcher_internal_error("Unknown exception: %s" % (e))
+ raise
+
def handleHeader(self, key, value):
More information about the apt-proxy-devel
mailing list