Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification After Modifying .py File: xx Has Been Modified but Not Loaded Yet. Hot Reloading Not Needed. #161

Open
saltyplum opened this issue Aug 23, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@saltyplum
Copy link

I've made sure that this file has been successfully loaded. I added a print statement at the very beginning of the file, and it outputs correctly when the program starts. Additionally, when calling this function in debug mode, it successfully locates the function.

@saltyplum
Copy link
Author

saltyplum commented Aug 24, 2023

I am using reloadium on the zhenxun_bot project, which is a chatbot developed based on the nonebot2 framework. After testing, I found that the "xx Has Been Modified but Not Loaded Yet." message appears mainly in the plugins module. All other modules can be reloaded properly, while the loading method for plugins is as follows:

import nonebot
nonebot.init()
# Load plugins
nonebot.load_plugins("src/plugins")
nonebot.run()

The loading of plugins is completed in the robot's entry file and needs to be done after framework initialization and before running.
I'm not sure if the loading method is causing the issue, and if it is, I hope to have support added for this situation. Thank you.

@saltyplum
Copy link
Author

saltyplum commented Aug 28, 2023

It doesn't work only in the __init__.py file, but it works in other .py files.

@dkrystki
Copy link
Contributor

Could you provide a reproducer (minimal code that reproduces the issue).
I'll try fixing it in the next release if you provide this.

@saltyplum
Copy link
Author

saltyplum commented Aug 29, 2023

The issue arises with the __init__.py file in Nonebot 2 plugin development. If you directly modify the __init__.py file, these modifications won't be hot-reloaded correctly. However, if you create a test.py file and import it in the __init__.py file, modifications made to the test.py file can be hot-reloaded successfully.
eg: __init__.py file

from nonebot import on_command
test = on_command("test")
@test.handle()
async def _():
    print('test')

@dkrystki dkrystki added the bug Something isn't working label Sep 14, 2023
@saltyplum
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants