Skip to content

Commit 1220a9e

Browse files
committed
docs: clarify scan_for_annotated_workers only finds already-imported modules
Document that scan_for_annotated_workers=True inspects sys.modules at init time — it does not scan the filesystem. Workers in unimported modules are silently ignored. Add clear workaround examples: import the module first, or use the import_modules parameter. Closes conductor-oss/getting-started#43
1 parent b686d6b commit 1220a9e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/conductor/client/automator/task_handler.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,29 @@ class TaskHandler:
149149
- 10-100x better concurrency for I/O-bound workloads
150150
- Automatically detected - no configuration needed
151151
152+
Parameters:
153+
scan_for_annotated_workers: When True (default), discovers workers decorated with
154+
@worker_task that have already been imported into the current Python process.
155+
This does NOT scan the filesystem — it only finds functions registered at
156+
import time. Workers defined in modules that have not yet been imported will
157+
be silently ignored.
158+
159+
To load workers from separate files, import them before creating TaskHandler:
160+
161+
import myapp.workers # must import first
162+
with TaskHandler(configuration=config) as th:
163+
th.start_processes()
164+
165+
Or use the import_modules parameter to have TaskHandler import them for you:
166+
167+
with TaskHandler(configuration=config,
168+
import_modules=['myapp.workers']) as th:
169+
th.start_processes()
170+
171+
import_modules: List of module dotted-path strings to import before scanning for
172+
annotated workers (e.g. ['myapp.workers', 'myapp.other_workers']). Use this
173+
instead of manual imports when scan_for_annotated_workers=True.
174+
152175
Usage:
153176
# Default configuration
154177
handler = TaskHandler(configuration=config)

0 commit comments

Comments
 (0)