Example #1
0
    def publish_all(self):
        while True:
            try:
                event = self.queue.popleft()
            except IndexError:
                break

            # Get subscribers to event and invoke them. The normal way to do
            # this in Pyramid is to invoke `registry.notify`, but that provides
            # no guarantee about the order of execution and any failure causes
            # later subscribers not to run.
            #
            # Here we wrap each subscriber call in an exception handler to
            # make failure independent in non-debug environments.
            subscribers = _get_subscribers(self.request.registry, event)
            for subscriber in subscribers:
                try:
                    subscriber(event)
                except Exception:
                    if event.request.debug:
                        raise
                    report_exception()
Example #2
0
    def publish_all(self):
        while True:
            try:
                event = self.queue.popleft()
            except IndexError:
                break

            # Get subscribers to event and invoke them. The normal way to do
            # this in Pyramid is to invoke `registry.notify`, but that provides
            # no guarantee about the order of execution and any failure causes
            # later subscribers not to run.
            #
            # Here we wrap each subscriber call in an exception handler to
            # make failure independent in non-debug environments.
            subscribers = _get_subscribers(self.request.registry, event)
            for subscriber in subscribers:
                try:
                    subscriber(event)
                except Exception:
                    if event.request.debug:
                        raise
                    report_exception()
Example #3
0
    def test_exc_defaults_to_None(self, sentry_sdk):
        report_exception()

        sentry_sdk.capture_exception.assert_called_once_with(None)
Example #4
0
    def test_it_reports_the_exception_to_Sentry(self, sentry_sdk):
        exc = ValueError("Test exception")

        report_exception(exc)

        sentry_sdk.capture_exception.assert_called_once_with(exc)
Example #5
0
    def test_exc_defaults_to_None(self, sentry_sdk):
        report_exception()

        sentry_sdk.capture_exception.assert_called_once_with(None)
Example #6
0
    def test_it_reports_the_exception_to_Sentry(self, sentry_sdk):
        exc = ValueError("Test exception")

        report_exception(exc)

        sentry_sdk.capture_exception.assert_called_once_with(exc)