-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Run uvicorn with multiple workers on Windows - WinError 5 #484
Comments
The initial warning is the relevant part here: "You must pass the application as an import string to enable 'reload' or 'workers'." Really we ought to be quitting uvicorn, rather than allowing it to run to failure after that message. (And change it from a warning to an error.) You'll need to use the following style instead... # If the application is `app` in module `example.py` -> Use "example:app"
uvicorn.run("example.app", host='0.0.0.0', port=8000,workers=2) |
Incidentally, are you seeing "�[0m" or proper terminal colours in the logs? |
tks,i change code like |
Looks to me like this should be closed via #487. Now released as 0.10.6. Let me know how that goes. |
i upgrade to 0.10.8,the error change to [WinError 10022],orz.. |
@grays820 try this workaround:
it should work, aparently the debug is set to False by default and this is what is causing the error |
yes,set debug=True,it work fine,why not support debug=False? |
Getting the same error message when trying to start a |
Not working |
Hey @WhitehatLaksh , Indeed, such an approach it is not working. You should try the approach proposed on [BUG] uvicorn can not start FastAPI with example settings, which is:
|
from starlette.applications import Starlette
from starlette.responses import JSONResponse
import uvicorn
app = Starlette(debug=True)
@app.route('/')
async def homepage(request):
return JSONResponse({'hello': 'world'})
@app.route('/long')
async def longpool(request):
z = 0
for x in range(1000000):
z = z+1
print(z)
return JSONResponse({'hello11': 'world'})
if name == 'main':
uvicorn.run(app, host='0.0.0.0', port=8000,workers=2)
error:
�[33mWARNING�[0m: You must pass the application as an import string to enable 'reload' or 'workers'.
�[32mINFO�[0m: Uvicorn running on �[1mhttp://0.0.0.0:8000�[0m (Press CTRL+C to quit)
�[32mINFO�[0m: Started parent process [�[36m�[1m40920�[0m]
Traceback (most recent call last):
File "main.py", line 29, in
uvicorn.run(app, host='0.0.0.0', port=8000,workers=2)
File "C:\Users\grays\Envs\python3\lib\site-packages\uvicorn\main.py", line 310, in run
supervisor.run(server.run, sockets=[sock])
File "C:\Users\grays\Envs\python3\lib\site-packages\uvicorn\supervisors\multiprocess.py", line 59, in run
process.start()
File "c:\python37\Lib\multiprocessing\process.py", line 112, in start
self._popen = self._Popen(self)
File "c:\python37\Lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "c:\python37\Lib\multiprocessing\popen_spawn_win32.py", line 65, in init
reduction.dump(process_obj, to_child)
File "c:\python37\Lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'request_response..app'
(python3) C:\Users\grays\Documents\Workspace\MyProjects\AnyTest>Traceback (most recent call last):
File "", line 1, in
File "c:\python37\Lib\multiprocessing\spawn.py", line 99, in spawn_main
new_handle = reduction.steal_handle(parent_pid, pipe_handle)
File "c:\python37\Lib\multiprocessing\reduction.py", line 87, in steal_handle
_winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] 拒绝访问。
already run cmd with Administrator mode
windows 10
uvicorn 0.10.4
starlette 0.12.13
The text was updated successfully, but these errors were encountered: