Skip to content

Commit f0c5eaf

Browse files
authored
MRG: Merge pull request #671 from octue/move-question-retrying-into-ask-method
Move question retrying into ask method
2 parents 84b418a + b143180 commit f0c5eaf

File tree

7 files changed

+404
-450
lines changed

7 files changed

+404
-450
lines changed

docs/source/asking_questions.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ You can also set the following options when you call :mod:`Child.ask <octue.reso
7070
- ``asynchronous`` - if ``True``, don't wait for an answer to the question (the result and other events can be :ref:`retrieved from the event store later <retrieving_asynchronous_answers>`)
7171
- ``timeout`` - how long in seconds to wait for an answer (``None`` by default - i.e. don't time out)
7272

73+
If the question fails:
74+
- If ``raise_errors=False``, the unraised error is returned
75+
- If ``raise_errors=False`` and ``max_retries > 0``, the question is retried up to this number of times
76+
- If ``raise_errors=False``, ``max_retries > 0``, and ``prevent_retries_when`` is a list of exception types, the question is retried unless the error type is in the list
77+
- If ``raise_errors=False``, ``log_errors=True``, and the question fails after its final retry, the error is logged
78+
79+
7380
Exceptions raised by a child
7481
----------------------------
7582
If a child raises an exception while processing your question, the exception will always be forwarded and re-raised in
@@ -185,8 +192,8 @@ access the event store and run:
185192

186193
Asking multiple questions in parallel
187194
=====================================
188-
You can also ask multiple questions to a service in parallel. By default, if any of the questions fail, an error is
189-
raised and no answers are returned.
195+
You can also ask multiple questions to a service in parallel - just provide questions as dictionaries of `Child.ask`
196+
arguments:
190197

191198
.. code-block:: python
192199
@@ -203,18 +210,11 @@ raised and no answers are returned.
203210
204211
This method uses multithreading, allowing all the questions to be asked at once instead of one after another.
205212

206-
**Options**
213+
.. hint::
207214

208-
- If ``raise_errors=False`` is provided, answers are returned for all successful questions while unraised errors are
209-
logged and returned for unsuccessful ones
210-
- If ``raise_errors=False`` is provided with ``max_retries > 0``, failed questions are retried up to this number of
211-
times
212-
- If ``raise_errors=False`` is provided with ``max_retries > 0`` and ``prevent_retries_when`` is set to a list of
213-
exception types, failed questions are retried except for those whose exception types are in the list
214-
- ``max_workers``: The maximum number of threads that can be used to ask questions in parallel can be set via this
215-
argument. It has no effect on the total number of questions that can be asked via ``Child.ask_multiple``.
216-
- ``log_errors``: If `True` and ``raise_errors=False``, any errors remaining once retries are exhausted are logged in
217-
addition to being returned
215+
The maximum number of threads that can be used to ask questions in parallel can be set via the ``max_workers``
216+
argument. It has no effect on the total number of questions that can be asked, just how many can be in progress at
217+
once.
218218

219219

220220
Asking a question within a service

docs/source/inter_service_compatibility.rst

+85-83
Large diffs are not rendered by default.

octue/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
logger = logging.getLogger(__name__)
99

1010

11-
PYTHONUNBUFFERED = "PYTHONUNBUFFERED"
1211
__all__ = ("Runner",)
1312

1413

@@ -22,9 +21,3 @@
2221
include_process_name=bool(int(os.environ.get("INCLUDE_PROCESS_NAME_IN_LOGS", 0))),
2322
include_thread_name=bool(int(os.environ.get("INCLUDE_THREAD_NAME_IN_LOGS", 0))),
2423
)
25-
26-
if not os.environ.get(PYTHONUNBUFFERED):
27-
logger.warning(
28-
f"The {PYTHONUNBUFFERED!r} environment variable isn't set - logs may not appear in real time. Set "
29-
f"{PYTHONUNBUFFERED}=1 to fix this."
30-
)

0 commit comments

Comments
 (0)