Skip to content

Commit eeac576

Browse files
authored
Fixed name resolving for some cases. (#27)
Signed-off-by: Pavel Kirilin <[email protected]>
1 parent b77d3a6 commit eeac576

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ extend-ignore = E203
66
docstring_style=sphinx
77

88
ignore =
9+
; Found a line that starts with a dot
10+
WPS348,
911
; `noqa` comments overuse ))))
1012
WPS402,
1113
; Found `%` string formatting

taskiq/abc/broker.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import inspect
2+
import os
3+
import sys
24
from abc import ABC, abstractmethod
35
from functools import wraps
46
from logging import getLogger
@@ -187,9 +189,18 @@ def inner(
187189
) -> AsyncTaskiqDecoratedTask[_FuncParams, _ReturnType]:
188190
nonlocal inner_task_name # noqa: WPS420
189191
if inner_task_name is None:
190-
inner_task_name = ( # noqa: WPS442
191-
f"{func.__module__}:{func.__name__}"
192-
)
192+
fmodule = func.__module__
193+
if fmodule == "__main__":
194+
fmodule = ".".join( # noqa: WPS220
195+
sys.argv[0]
196+
.removesuffix(
197+
".py",
198+
)
199+
.split(
200+
os.path.sep,
201+
),
202+
)
203+
inner_task_name = f"{fmodule}:{func.__name__}" # noqa: WPS442
193204
wrapper = wraps(func)
194205

195206
decorated_task = wrapper(

0 commit comments

Comments
 (0)