| 98 | ] |
| 99 | |
| 100 | def do_action(self, context, action): |
| 101 | if action.type == "clear": |
| 102 | raise NotImplementedError(f"{action.type} is not implemented.") |
| 103 | elif action.type == "healthcheck": |
| 104 | pass |
| 105 | elif action.type == "shutdown": |
| 106 | yield pyarrow.flight.Result(pyarrow.py_buffer(b'Shutdown!')) |
| 107 | # Shut down on background thread to avoid blocking current |
| 108 | # request |
| 109 | threading.Thread(target=self._shutdown).start() |
| 110 | else: |
| 111 | raise KeyError(f"Unknown action {action.type!r}") |
| 112 | |
| 113 | def _shutdown(self): |
| 114 | """Shut down after a delay.""" |