Skip to content

Commit a6bf5ce

Browse files
committed
docs about raise_on_cancel
1 parent 2f38511 commit a6bf5ce

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ for path in crawler.go(token=TimeoutToken(0.0001)): # Limit the iteration time t
157157

158158
> ↑ Follow these rules to avoid accidentally "baking" an expired token inside a crawler object.
159159
160+
By default, cancellation stops iteration silently — the caller cannot tell it apart from natural exhaustion. Pass `raise_on_cancel=...` to make the crawler raise an exception on cancellation instead:
161+
162+
```python
163+
for path in Crawler('.', token=TimeoutToken(0.0001), raise_on_cancel=True):
164+
print(path)
165+
```
166+
167+
> `raise_on_cancel=True` re-raises the native `cantok` exception; `raise_on_cancel=MyError("...")` raises that exact instance; `raise_on_cancel=MyError` instantiates the class with the cantok message and raises that. Default is `False` (silent).
168+
160169

161170
## Combination
162171

0 commit comments

Comments
 (0)