OSDN Git Service

Added exception handling
authorHirotaka Kawata <hktechno@hotmail.com>
Wed, 17 Feb 2010 16:49:07 +0000 (01:49 +0900)
committerHirotaka Kawata <hktechno@hotmail.com>
Wed, 17 Feb 2010 16:49:07 +0000 (01:49 +0900)
twitterapi.py

index 4a859ae..2a58306 100644 (file)
@@ -4,6 +4,7 @@
 import twoauth
 import threading
 import time
+import sys
 
 # Twitter API Class
 class twitterapi():
@@ -39,8 +40,12 @@ class timeline_thread(threading.Thread):
     # Thread run
     def run(self):
         while True:
-            # Get Timeline
-            self.last = self.func(*self.args, **self.kwargs)
+            try:
+                # Get Timeline
+                self.last = self.func(*self.args, **self.kwargs)
+            except Exception, e:
+                self.last = list()
+                print >>sys.stderr, "Error", e
             
             # If Timeline update
             if self.last: