Skip to content

Commit b5b4d21

Browse files
committed
Fix document layout
1 parent 2f92ab4 commit b5b4d21

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

docs/_advanced/lazy_listener_functions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def handler(event, context):
6363
<div class="secondary-content" markdown="0">
6464

6565
For common Bolt apps, you can call `ack()` at the beginning of a listener function this way:
66+
</div>
6667

6768
```python
6869
@app.shortcut("callback-id-here")
@@ -71,7 +72,9 @@ def open_modal(ack, body, client):
7172
run_time_consuming_operation_here()
7273
```
7374

75+
<div class="secondary-content" markdown="0">
7476
However, if you run your app on FaaS or a similar runtime (that doesn't allow running threads/processes after returning an HTTP response), you will use the `process_before_response=True` option to hold off sending an HTTP response util completing all the tasks in a listener. In this case, all your listener functions must complete within 3 seconds.
77+
</div>
7578

7679
```python
7780
app = App(process_before_response=True)
@@ -82,12 +85,14 @@ def this_always_times_out(ack):
8285
time.sleep(5)
8386
```
8487

88+
<div class="secondary-content" markdown="0">
8589
To deal with this, you can use keyword args `ack: Callable` and `lazy: List[Callable]`:
8690

8791
* `ack: Callable` is responsible for calling `ack()`
8892
* `lazy: List[Callable]` are unable to call `ack()` but can do any time consuming operations in a separate execution (in a thread, another AWS Lambda invocation, and so on)
8993

9094
Instead of acting as a decorator for a method, `App`/`AsyncApp`'s methods takes keyword args as below.
95+
</div>
9196

9297
```python
9398
app.command("/start-process")(
@@ -97,6 +102,5 @@ app.command("/start-process")(
97102
lazy=[run_long_process]
98103
)
99104
```
100-
</div>
101105

102106
</details>

0 commit comments

Comments
 (0)