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

启动报错 #2985

Open
1 task done
f754699 opened this issue Jul 13, 2024 · 2 comments · May be fixed by #2992
Open
1 task done

启动报错 #2985

f754699 opened this issue Jul 13, 2024 · 2 comments · May be fixed by #2992
Labels

Comments

@f754699
Copy link

f754699 commented Jul 13, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

 File "F:\pythonproject\sanicResolve2\.venv\Lib\site-packages\sanic\mixins\startup.py", line 1180, in serve
    while cls._get_process_states(worker_state):
                                  ^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'worker_state' where it is not associated with a value

Code snippet

from sanic import Sanic, text, json

app = Sanic("fuwu")

if __name__ == '__main__':
    app.run(host="0,0,0,0", port=8000, )

Expected Behavior

启动就报错,

How do you run Sanic?

as a model

Operating System

Windows

Sanic Version

sanic = {extras = ["ext"], version = "^24.6.0"}

Additional context

No response

@ChihweiLHBird
Copy link
Member

ChihweiLHBird commented Jul 18, 2024

from sanic import Sanic, text, json

app = Sanic("fuwu")

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=8000)

Setting the correct host name seems to address the issue. But we might want to implement a host name validator to avoid confusing error message.

host里的,改为.即可解决问题。同时建议在Linux或Unix系统上尝试

pygeek added a commit to pygeek/sanic that referenced this issue Jul 31, 2024
@pygeek pygeek linked a pull request Jul 31, 2024 that will close this issue
pygeek added a commit to pygeek/sanic that referenced this issue Jul 31, 2024
@pygeek
Copy link

pygeek commented Jul 31, 2024

This is still a bug, however. mixins.startup.serve should still exit gracefully—fixed in my PR.

pygeek added a commit to pygeek/sanic that referenced this issue Jul 31, 2024
pygeek added a commit to pygeek/sanic that referenced this issue Jul 31, 2024
pygeek added a commit to pygeek/sanic that referenced this issue Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants