Commits

Mahmoud Abdelkader committed ff7a6d0

Fixed a typo, added better documentation, and fixed a small bug with exceptions

Comments (0)

Files changed (1)

hoptoad/middleware.py

         pass
 
 def _exception_handler(request, exc_info):
-    """Rudimentary exception handler, simply logs and moves on."""
+    """Rudimentary exception handler, simply logs and moves on. If there's no
+    tuple, it means something went really wrong. Critically log and exit."""
     if not isinstance(exc_info, tuple):
         # Something is seriously wrong...
         logger.critical(str(request))
         logger.critical(str(exc_info))
-        raise SystemExit
+        sys.exit(1)
     logger.warn("**** Exception occured in request #%s: %s" % \
                 (request.requestID, exc_info))
 
         self.daemon = True #daemon thread..important!
         self.pool = ThreadPool(self.threads)
 
-    def enqueue(self, payload, timeout, callback=None, exc_callback=_infodump):
+    def enqueue(self, 
+                payload, 
+                timeout, 
+                callback=None, 
+                exc_callback=_exception_handler):
         #create the worker request
         request = WorkRequest(_ride_the_toad, 
                               args=(payload, timeout), 
         """
         while True:
             try:
-                time.sleep(0.5) #configure?
+                time.sleep(0.5) #TODO: configure for tuning
                 self.pool.poll()
             except KeyboardInterrupt:
                 logger.info("***** Interrupted!")
         self.thread.enqueue(payload, self.timeout)
         
         return None
-