fix: Import bisheng_celery in worker init file#1784
Merged
zgqgit merged 2 commits intodataelement:mainfrom Nov 28, 2025
Merged
Conversation
Avoid writing 'from bisheng. worker import bisheng_celery' that depends on submodules
Collaborator
|
如果import 顺序发生变化,可能会发生循环引用的报错,可以把各个task里的引用改为从main引用 |
Contributor
Author
我把出现 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
我发现worker的task中存在比较多如下写法:
目前这种写法依赖task中存在
from bisheng.worker.main import bisheng_celery的写法,而bisheng/worker/__init__.py中将所有task注册导致目前的写法正常。目前,如果我将

bisheng/worker/test/test.py和bisheng/worker/workflow/tasks.py中from bisheng.worker.main import bisheng_celery的写法注释掉,则task中的import bisheng_celery将会报错,例如file_worker中的代码显示:这是一种看起来比较奇怪的现象:
workflow/tasks.py和test/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的写法正常