Skip to content

Commit 69cec68

Browse files
authored
Update get_functions.py script now it raises exception on duplication (#78)
1 parent 1ee4eb5 commit 69cec68

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

crates/fluxqueue-worker/scripts/get_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def list_functions(module_path: str, queue: str):
1212
continue
1313

1414
if inspect.isfunction(obj) or (inspect.isbuiltin(obj) and task_name):
15+
if funcs.get(task_name):
16+
raise ValueError(f"Task name '{task_name}' is duplicated")
17+
1518
original_func = getattr(obj, "__wrapped__", obj)
1619
funcs[task_name] = original_func
1720
return funcs

crates/fluxqueue-worker/src/task.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ impl TaskRegistry {
1414
}
1515
}
1616

17-
// TODO: Add task name duplication error
1817
pub fn insert(&self, name: String, func: Py<PyAny>) -> Result<()> {
1918
let mut tasks = self.tasks.write().map_err(|_| {
2019
anyhow::anyhow!("Internal Error: Task registry lock poisoned (a thread panicked)")

crates/fluxqueue-worker/src/worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ fn get_task_functions(module_path: &str, queue_name: &str) -> Result<Vec<(String
340340

341341
let py_funcs: Bound<'_, PyDict> = module
342342
.getattr("list_functions")
343-
.map_err(|e| anyhow!("Failed to get 'list_functions': {}", e))?
343+
.map_err(|e| anyhow!("Failed to get 'list_functions' script: {}", e))?
344344
.call1((real_module_path, queue_name))
345-
.map_err(|e| anyhow!("Failed to execute 'list_functions' to get tasks: {}", e))?
345+
.map_err(|e| anyhow!("Failed to get tasks: {}", e))?
346346
.cast_into::<PyDict>()
347347
.map_err(|_| anyhow!("Failed to cast result to a Python Dictionary"))?;
348348

0 commit comments

Comments
 (0)