File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,28 @@ def inner(
346346 inner_labels = labels or {},
347347 )
348348
349+ def register_task (
350+ self ,
351+ func : Callable [_FuncParams , _ReturnType ],
352+ task_name : Optional [str ] = None ,
353+ ** labels : Any ,
354+ ) -> AsyncTaskiqDecoratedTask [_FuncParams , _ReturnType ]:
355+ """
356+ API for registering tasks programmatically.
357+
358+ This function is basically the same as `task` decorator,
359+ but it doesn't decorate function, it just registers it
360+ and returns AsyncTaskiqDecoratedTask object, that can
361+ be called later.
362+
363+ :param func: function to register.
364+ :param task_name: custom name of a task, defaults to qualified function's name.
365+ :param labels: some addition labels for task.
366+
367+ :returns: registered task.
368+ """
369+ return self .task (task_name = task_name , ** labels )(func )
370+
349371 def on_event (self , * events : TaskiqEvents ) -> Callable [[EventHandler ], EventHandler ]:
350372 """
351373 Adds event handler.
You can’t perform that action at this time.
0 commit comments