We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Sanic.start_method="fork"
INSPECTOR=True
When I set Sanic's start_method to fork and enable INSPECTOR, the HTTP requests I send may unexpectedly be processed by the INSPECTOR worker process.
start_method
fork
INSPECTOR
Could this be because the webserver socket inherited from the parent process is not closed when forking the child process?
If there are any suggestions, or if this behavior is expected, please let me know. Thank you to all the excellent library developers.
test server code:
from sanic import Sanic, Request, HTTPResponse, json import os Sanic.start_method = "fork" app = Sanic("test-fork-with-inspector", inspector=True) @app.get("/test") async def test_handler(_: Request) -> HTTPResponse: return json(body={"pid": os.getpid()})
running server and sending HTTP request:
python -m sanic test_fork_with_inspector:app --worker=1 --host=127.0.0.1 --port=8080 curl -X GET http://localhost:8080/test {"pid":1199437} # inspector worker curl -X GET http://localhost:8080/test {"pid":1199435} # nomal worker
Socket fd of inspector worker:
lsof -p 1199437 | grep LISTEN python 1199437 user 12u IPv4 24318245 0t0 TCP localhost:http-alt (LISTEN) python 1199437 user 15u IPv4 24311762 0t0 TCP localhost:6457 (LISTEN)
Socket fd of normal worker:
lsof -p 1199435 | grep LISTEN python 1199435 tusen 12u IPv4 24318245 0t0 TCP localhost:http-alt (LISTEN)
inspector worker should not handle regular HTTP requests
Sanic CLI Python3.8.10
Ubuntu 20.04
Sanic 23.12.0; Routing 23.12.0
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is there an existing issue for this?
Describe the bug
When I set Sanic's
start_method
tofork
and enableINSPECTOR
, the HTTP requests I send may unexpectedly be processed by theINSPECTOR
worker process.Could this be because the webserver socket inherited from the parent process is not closed when forking the child process?
If there are any suggestions, or if this behavior is expected, please let me know. Thank you to all the excellent library developers.
Code snippet
test server code:
running server and sending HTTP request:
Socket fd of inspector worker:
lsof -p 1199437 | grep LISTEN python 1199437 user 12u IPv4 24318245 0t0 TCP localhost:http-alt (LISTEN) python 1199437 user 15u IPv4 24311762 0t0 TCP localhost:6457 (LISTEN)
Socket fd of normal worker:
lsof -p 1199435 | grep LISTEN python 1199435 tusen 12u IPv4 24318245 0t0 TCP localhost:http-alt (LISTEN)
Expected Behavior
inspector worker should not handle regular HTTP requests
How do you run Sanic?
Sanic CLI Python3.8.10
Operating System
Ubuntu 20.04
Sanic Version
Sanic 23.12.0; Routing 23.12.0
Additional context
No response
The text was updated successfully, but these errors were encountered: