Esempio n. 1
0
def stub_broker():
    broker = StubBroker()
    broker.emit_after("process_boot")
    remoulade.set_broker(broker)
    yield broker
    broker.flush_all()
    broker.emit_before("process_stop")
    broker.close()
Esempio n. 2
0
def test_shutdown_notifications_platform_not_supported(recwarn, monkeypatch):
    # monkeypatch fake platform to test logging.
    monkeypatch.setattr(shutdown, "current_platform", "not supported")

    # Given a broker configured with the shutdown notifier
    broker = StubBroker(middleware=[shutdown.ShutdownNotifications()])

    # When the process boots
    broker.emit_after("process_boot")

    # A platform support warning is issued
    assert len(recwarn) == 1
    assert str(
        recwarn[0].message) == ("ShutdownNotifications cannot kill threads "
                                "on your current platform ('not supported').")
Esempio n. 3
0
def test_no_timer_signal_after_shutdown():
    # Given a broker
    broker = StubBroker()

    # With a TimeLimit middleware
    for middleware in broker.middleware:
        if isinstance(middleware, TimeLimit):
            # That emit a signal every ms
            middleware.interval = 1

    broker.emit_after("process_boot")

    handler = Mock()

    signal.signal(signal.SIGALRM, handler)

    broker.emit_before("process_stop")

    # If i wait enough time to get a signal
    time.sleep(2 / 1000)

    # No signal should have been sent
    assert not handler.called