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
Update sync dependency examples to avoid blocking I/O
Replace examples showing blocking operations (file I/O, locks) with
non-blocking patterns:
- Pure computations (config merging, param building)
- In-memory operations (dict/set access)
- Quick transformations
Add clear guidance that sync dependencies should NEVER include
blocking I/O operations. All I/O must use async dependencies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/dependencies.md
+93-35Lines changed: 93 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,21 +160,40 @@ Timeouts work alongside retries. If a task times out, it can be retried accordin
160
160
161
161
## Custom Dependencies
162
162
163
-
Create your own dependencies using `Depends()` for reusable resources and patterns. Dependencies can be either synchronous or asynchronous:
163
+
Create your own dependencies using `Depends()` for reusable resources and patterns. Dependencies can be either synchronous or asynchronous.
164
+
165
+
**Important**: Synchronous dependencies should **NOT** include blocking I/O operations (file access, network calls, database queries, etc.). Use async dependencies for any I/O. Sync dependencies are best for:
166
+
- Pure computations
167
+
- In-memory data structure access
168
+
- Configuration lookups from memory
169
+
- Non-blocking transformations
164
170
165
171
### Synchronous Dependencies
166
172
173
+
Use sync dependencies for pure computations and in-memory operations:
174
+
167
175
```python
168
176
from docket import Depends
169
177
178
+
# In-memory config lookup - no I/O
170
179
defget_config() -> dict:
171
-
"""Simple sync dependency that returns configuration."""
0 commit comments