File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,28 @@ def sleep():
105105 t .join ()
106106
107107
108+ @pytest .mark .xfail (reason = "Graceful shutdown is currently failing" )
109+ def test_graceful_shutdown_waits_for_in_flight_request (defaultenv ):
110+ "SIGTERM should allow in-flight requests to finish before exiting"
111+
112+ with run (env = defaultenv , wait_max_seconds = 5 ) as postgrest :
113+
114+ def sleep ():
115+ response = postgrest .session .get ("/rpc/sleep?seconds=3" , timeout = 10 )
116+ assert response .text == ""
117+ assert response .status_code == 204
118+
119+ t = Thread (target = sleep )
120+ t .start ()
121+
122+ # Wait for the request to be in-flight before shutting down.
123+ time .sleep (1 )
124+
125+ postgrest .process .terminate ()
126+
127+ t .join ()
128+
129+
108130def test_random_port_bound (defaultenv ):
109131 "PostgREST should bind to a random port when PGRST_SERVER_PORT is 0."
110132
You can’t perform that action at this time.
0 commit comments