You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typically you will not want the block to execute if an exception occurs inside the `with` block. However, in the case that this is desirable, it's achievable by using the following syntax:
50
+
Typically you will not want the block to execute if an exception occurs inside the `with` block. However, in the case that this is desirable, it's achievable by using the following syntax:
51
51
52
-
.. code-block:: python
52
+
.. code-block:: python
53
53
54
-
with BatchQuery(execute_on_exception=True) as b:
55
-
LogEntry.batch(b).create(k=1, v=1)
56
-
mystery_function() # exception thrown in here
57
-
LogEntry.batch(b).create(k=1, v=2) # this code is never reached due to the exception, but anything leading up to here will execute in the batch.
54
+
with BatchQuery(execute_on_exception=True) as b:
55
+
LogEntry.batch(b).create(k=1, v=1)
56
+
mystery_function() # exception thrown in here
57
+
LogEntry.batch(b).create(k=1, v=2) # this code is never reached due to the exception, but anything leading up to here will execute in the batch.
58
58
59
-
If an exception is thrown somewhere in the block, any statements that have been added to the batch will still be executed. This is useful for some logging situations.
59
+
If an exception is thrown somewhere in the block, any statements that have been added to the batch will still be executed. This is useful for some logging situations.
60
60
61
61
Batch Query Execution Callbacks
62
62
===============================
63
63
64
-
In order to allow secondary tasks to be chained to the end of batch, BatchQuery instances allow callbacks to be
65
-
registered with the batch, to be executed immediately after the batch executes.
64
+
In order to allow secondary tasks to be chained to the end of batch, BatchQuery instances allow callbacks to be
65
+
registered with the batch, to be executed immediately after the batch executes.
66
66
67
-
Multiple callbacks can be attached to same BatchQuery instance, they are executed in the same order that they
68
-
are added to the batch.
67
+
Multiple callbacks can be attached to same BatchQuery instance, they are executed in the same order that they
68
+
are added to the batch.
69
69
70
-
The callbacks attached to a given batch instance are executed only if the batch executes. If the batch is used as a
71
-
context manager and an exception is raised, the queued up callbacks will not be run.
70
+
The callbacks attached to a given batch instance are executed only if the batch executes. If the batch is used as a
71
+
context manager and an exception is raised, the queued up callbacks will not be run.
0 commit comments