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

dynamic update blueprint #2991

Open
1 task done
amoxuk opened this issue Jul 26, 2024 · 1 comment
Open
1 task done

dynamic update blueprint #2991

amoxuk opened this issue Jul 26, 2024 · 1 comment
Labels

Comments

@amoxuk
Copy link

amoxuk commented Jul 26, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

some package in my folder, I want add new package in the folder at sanic running.

@app.get('xx')
async def reload(rq):
for folder in os.listdir('somefolder'):
pkg = importlib.import_module(folder)
_lib.append(pkg.app)
bp = Bleprint.group(*_lib,url_prefix='/someurl')
app.router.reset()
app.blueprint(bp)

reload success but use the url throw error.
Nonetype object is not callable in sanic router

Code snippet

No response

Expected Behavior

No response

How do you run Sanic?

As a script (app.run or Sanic.serve)

Operating System

Linux

Sanic Version

22.12.0

Additional context

No response

@amoxuk amoxuk added the bug label Jul 26, 2024
@amoxuk
Copy link
Author

amoxuk commented Jul 26, 2024

add app.finalize() to solve this problem.

But here is a new problem.

After reload, I can request the blueprint's url many times if I refresh the browser quickly, but it returns 404 after the sanic logs 'KeepAlive Timeout,Closing cojnextion.'.

It looks like I reload a temp variable of 'app'.

How to reload the gloable app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant