Shinya Okano avatar Shinya Okano committed 5e3dd91

refs #6 force reconnect skype on SkypeAPIError

Comments (0)

Files changed (2)

src/skypehub/handlers.py

 from time import time
 from struct import pack, unpack
 
+from Skype4Py.errors import SkypeAPIError
+
 from skypehub.models import Message
-from skypehub.utils import is_windows
+from skypehub.utils import is_windows, get_skype
 
 
 def message_logging_receiver(handler, message, status):
             self.receivers[status].add(receiver)
 
     def dispatch(self, message, status):
-        for receiver in self.receivers[status]:
-            receiver(self, message, status)
+        try:
+            for receiver in self.receivers[status]:
+                receiver(self, message, status)
+        except SkypeAPIError, err:
+            # reconnect skype
+            get_skype(force_create=True)
 
 
 class OnTimeHandler(object):

src/skypehub/management/commands/runskypebot.py

 
 from skypehub.utils import skype
 
+
 class Command(BaseCommand):
     option_list = BaseCommand.option_list + (
         make_option('--daemonize', action='store_true',
-                dest='daemonize', help='daemonize bot.'),
+                    dest='daemonize', help='daemonize bot.'),
         make_option('--pidfile', dest='pidfile', default=None,
-                help='create pid file.'),
+                    help='create pid file.'),
     )
     help = "run skype bot."
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.