Skip to content

fix: Import bisheng_celery in worker init file#1784

Merged
zgqgit merged 2 commits intodataelement:mainfrom
ieayoio:patch-1
Nov 28, 2025
Merged

fix: Import bisheng_celery in worker init file#1784
zgqgit merged 2 commits intodataelement:mainfrom
ieayoio:patch-1

Conversation

@ieayoio
Copy link
Copy Markdown
Contributor

@ieayoio ieayoio commented Nov 27, 2025

我发现worker的task中存在比较多如下写法:

from bisheng.worker import bisheng_celery

目前这种写法依赖task中存在from bisheng.worker.main import bisheng_celery的写法,而bisheng/worker/__init__.py中将所有task注册导致目前的写法正常。

目前,如果我将bisheng/worker/test/test.pybisheng/worker/workflow/tasks.pyfrom bisheng.worker.main import bisheng_celery的写法注释掉,则task中的import bisheng_celery将会报错,例如file_worker中的代码显示:
image

这是一种看起来比较奇怪的现象:workflow/tasks.pytest/test.py的import影响了knowledge/file_worker.py,究其原因是因为bisheng/worker/__init__.py中将所有task注册导致表现正常,我认为更合理的做法应该是将from bisheng.worker.main import bisheng_celery加到我修改地方,保证from bisheng.worker import bisheng_celery的写法正常

Avoid writing 'from bisheng. worker import bisheng_celery' that depends on submodules
@zgqgit
Copy link
Copy Markdown
Collaborator

zgqgit commented Nov 27, 2025

如果import 顺序发生变化,可能会发生循环引用的报错,可以把各个task里的引用改为从main引用

@ieayoio
Copy link
Copy Markdown
Contributor Author

ieayoio commented Nov 27, 2025

如果import 顺序发生变化,可能会发生循环引用的报错,可以把各个task里的引用改为从main引用

我把出现from bisheng.worker import bisheng_celery的地方都改为了from bisheng.worker.main import bisheng_celery,主要出现在knowledge里

@zgqgit zgqgit merged commit 9cf02e0 into dataelement:main Nov 28, 2025
@ieayoio ieayoio deleted the patch-1 branch November 28, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants