Commits

Anonymous committed 56c1c72

Added a blocking implementation of a hoptoad handler

Comments (0)

Files changed (2)

hoptoad/handlers/__init__.py

 
 from hoptoad import get_hoptoad_settings
 from hoptoad.handlers.threaded import ThreadedNotifier
+from hoptoad.handlers.blocking import BlockingNotifier
 
 logger = logging.getLogger(__name__)
 
     if handler.lower() == 'threadpool':
         threads = hoptoad_settings.get("HOPTOAD_THREAD_COUNT", 4)
         return ThreadedNotifier(threads , *args, **kwargs)
+    elif handler.lower() == 'blocking':
+        return BlockingNotifier(*args, **kwargs)

hoptoad/handlers/blocking.py

+import os
+import time
+import logging
+
+from hoptoad.api import htv2
+
+logger = logging.getLogger(__name__)
+
+class BlockingNotifier(object):
+    """A blocking Hoptoad notifier.  """
+    def __init__(self):
+        _threadname = "Hoptoad%s-%d" % (self.__class__.__name__, os.getpid())
+
+    def enqueue(self, payload, timeout):
+        htv2.report(payload, timeout)