Add simple multiprocessing test
@@ -30,3 +30,28 @@ def test_run():
response = requests.get("http://127.0.0.1:8000")
assert response.status_code == 204
thread.join()
+
+
+def test_run_multiprocess():
+ class App:
+ def __init__(self, scope):
+ if scope["type"] != "http":
+ raise Exception()
+
+ async def __call__(self, receive, send):
+ await send({"type": "http.response.start", "status": 204, "headers": []})
+ await send({"type": "http.response.body", "body": b"", "more_body": False})
+
+ class CustomServer(Server):
+ def install_signal_handlers(self):
+ pass
+
+ config = Config(app=App, loop="asyncio", workers=2, limit_max_requests=1)
+ server = CustomServer(config=config)
+ thread = threading.Thread(target=server.run)
+ thread.start()
+ while not server.started:
+ time.sleep(0.01)
+ response = requests.get("http://127.0.0.1:8000")
+ assert response.status_code == 204
+ thread.join()
