-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap the FlightSQL server native class in a Python class that manages…
… its own thread (#480) * Create wrapper functions for FlightSqlServer methods, add pybindings to server * Add gil release call guard in binding, create async function for serve * Wrap FlightSQL native class in Python class with own thread * Remove unused import * Address formatting and pylint errors * Add Union from typing, reformat flight_sql_server.py * Address comments: add types, move server start, use Optional --------- Co-authored-by: Sophie Zhang <[email protected]>
- Loading branch information
Showing
5 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import threading | ||
|
||
# pylint: disable-next=import-error,no-name-in-module,unused-import | ||
import brad.native.pybind_brad_server as brad_server | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class BradFlightSqlServer: | ||
def __init__(self, host: str, port: int) -> None: | ||
self._flight_sql_server = brad_server.BradFlightSqlServer() | ||
self._flight_sql_server.init(host, port) | ||
self._thread = threading.Thread(name="BradFlightSqlServer", target=self._serve) | ||
|
||
def start(self) -> None: | ||
self._thread.start() | ||
|
||
def stop(self) -> None: | ||
logger.info("BRAD FlightSQL server stopping...") | ||
self._flight_sql_server.shutdown() | ||
self._thread.join() | ||
logger.info("BRAD FlightSQL server stopped.") | ||
|
||
def _serve(self) -> None: | ||
self._flight_sql_server.serve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters