MCPcopy Create free account
hub / github.com/apache/arrow / ServeWithSignals

Method ServeWithSignals

python/pyarrow/src/arrow/python/flight.cc:180–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180Status PyFlightServer::ServeWithSignals() {
181 // Respect the current Python settings, i.e. only interrupt the server if there is
182 // an active signal handler for SIGINT and SIGTERM.
183 std::vector<int> signals;
184 for (const int signum : {SIGINT, SIGTERM}) {
185 ARROW_ASSIGN_OR_RAISE(auto handler, ::arrow::internal::GetSignalHandler(signum));
186 auto cb = handler.callback();
187 if (cb != SIG_DFL && cb != SIG_IGN) {
188 signals.push_back(signum);
189 }
190 }
191 RETURN_NOT_OK(SetShutdownOnSignals(signals));
192
193 // Serve until we got told to shutdown or a signal interrupted us
194 RETURN_NOT_OK(Serve());
195 int signum = GotSignal();
196 if (signum != 0) {
197 // Issue the signal again with Python's signal handlers restored
198 PyAcquireGIL lock;
199 raise(signum);
200 // XXX Ideally we would loop and serve again if no exception was raised.
201 // Unfortunately, gRPC will return immediately if Serve() is called again.
202 ARROW_UNUSED(PyErr_CheckSignals());
203 }
204
205 return Status::OK();
206}
207
208PyFlightResultStream::PyFlightResultStream(PyObject* generator,
209 PyFlightResultStreamCallback callback)

Callers

nothing calls this directly

Calls 3

push_backMethod · 0.80
OKFunction · 0.50
callbackMethod · 0.45

Tested by

no test coverage detected