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