Skip to content

Commit a06f1e3

Browse files
committed
Change StubBroker.join() parameter fail_fast to default to True
Resolves #739
1 parent 352f6b1 commit a06f1e3

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

docs/source/guide.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,17 +490,18 @@ synchronously by calling them as you would normal functions.
490490
Dealing with Exceptions
491491
^^^^^^^^^^^^^^^^^^^^^^^^
492492

493-
By default, any exceptions raised by an actor are raised in the
493+
By default, any exceptions raised by an actor are caught by the
494494
worker, which runs in a separate thread from the one your tests run
495495
in. This means that any exceptions your actor throws will not be
496-
visible to your test code!
496+
immediately visible to your test code!
497497

498-
You can make the stub broker re-raise exceptions from failed actors in your
499-
main thread by passing ``fail_fast=True`` to its ``join`` method::
498+
To help surface actor exceptions, by default,
499+
the stub broker will re-raise exceptions from failed messages
500+
in your main thread when you call its |StubBroker_join| method::
500501

501502
def test_count_words(stub_broker, stub_worker):
502-
count_words.send("http://example.com")
503-
stub_broker.join(count_words.queue_name, fail_fast=True)
503+
count_words.send("http://some-invalid-url.invalid")
504+
stub_broker.join(count_words.queue_name) # Exception from actor will be re-raised here.
504505
stub_worker.join()
505506

506507
This way, whatever exception caused the actor to fail will be raised

docs/source/troubleshooting.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ pytest_, then you can easily do this from the command line using the
5858

5959
You can also pass ``fail_fast=True`` as a parameter to |StubBroker_join|
6060
in order to make it reraise whatever exception caused the actor to
61-
fail in the main thread. Note, however, that the actor is only
61+
fail in the main thread.
62+
63+
.. versionchanged:: 2.0.0
64+
The ``fail_fast`` parameter now defaults to True.
65+
66+
Note, however, that the actor is only
6267
considered to fail once all of its retries have been used up; meaning
6368
that unless you specify custom retry limits for the actors or for your
6469
tests as a whole (by configuring the |Retries| middleware), then each

dramatiq/brokers/stub.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ def flush_all(self) -> None:
131131

132132
self.dead_letters_by_queue.clear()
133133

134-
# TODO: Make fail_fast default to True.
135-
def join(self, queue_name: str, *, timeout: Optional[int] = None, fail_fast: bool = False) -> None:
134+
def join(self, queue_name: str, *, timeout: Optional[int] = None, fail_fast: bool = True) -> None:
136135
"""Wait for all the messages on the given queue to be
137136
processed. This method is only meant to be used in tests
138137
to wait for all the messages in a queue to be processed.
@@ -145,10 +144,13 @@ def join(self, queue_name: str, *, timeout: Optional[int] = None, fail_fast: boo
145144
queue_name(str): The queue to wait on.
146145
fail_fast(bool): When this is True and any message gets
147146
dead-lettered during the join, then an exception will be
148-
raised. This will be True by default starting with
149-
version 2.0.
147+
raised. When False, no exception will be raised.
148+
Defaults to True.
150149
timeout(Optional[int]): The max amount of time, in
151150
milliseconds, to wait on this queue.
151+
152+
.. versionchanged:: 2.0.0
153+
The ``fail_fast`` parameter now defaults to True.
152154
"""
153155
try:
154156
queues = [

0 commit comments

Comments
 (0)