From 2f08c5529a66bead4f3076fe65184a207bcf32ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 17 Apr 2014 15:33:21 +0200 Subject: [PATCH] improved exception handling --- ekgplotter/ekgplotter/main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index daa01cf..e4fc94c 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -394,10 +394,10 @@ class MyHandler(BaseHTTPRequestHandler): JpegData = buffer.data() self.wfile.write("--aaboundary\r\nContent-Type: image/jpeg\r\nContent-length: %d\r\n\r\n%s\r\n\r\n\r\n" % (len(JpegData), JpegData)) - del JpegData - del buffer - del img - del exporter + JpegData = None + buffer = None + img = None + exporter = None #now = time.time() #dt = now - lastTime #lastTime = now @@ -418,18 +418,18 @@ class MyHandler(BaseHTTPRequestHandler): return except (KeyboardInterrupt, SystemError): print "queue size", queue.qsize() - if hasattr(self, "thread"): + if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() - del self.thread + self.thread = None except IOError, e: print "ioerror", e, e[0] print dir(e) - if e[0] == 32: - if hasattr(self, "thread"): + if e[0] in (32, 104): + if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() - del self.thread + self.thread = None else: print '-'*40 print 'Exception happened during processing of request from'