Spawn the background worker. ``schemas=None`` defers resolution to the worker, which lists every database via its own dedicated connection — the main thread's ``sqlexecute`` must not be used here since the worker would race with the REPL.
(self, schemas: Iterable[str] | None)
| 95 | self._start([schema]) |
| 96 | |
| 97 | def _start(self, schemas: Iterable[str] | None) -> None: |
| 98 | """Spawn the background worker. |
| 99 | |
| 100 | ``schemas=None`` defers resolution to the worker, which lists |
| 101 | every database via its own dedicated connection — the main |
| 102 | thread's ``sqlexecute`` must not be used here since the worker |
| 103 | would race with the REPL. |
| 104 | """ |
| 105 | self.stop() |
| 106 | queue: list[str] | None = None if schemas is None else list(schemas) |
| 107 | self._cancel = threading.Event() |
| 108 | self._thread = threading.Thread( |
| 109 | target=self._run, |
| 110 | args=(queue,), |
| 111 | name='schema_prefetcher', |
| 112 | daemon=True, |
| 113 | ) |
| 114 | self._thread.start() |
| 115 | self._invalidate_app() |
| 116 | |
| 117 | def _run(self, schemas: list[str] | None) -> None: |
| 118 | executor: SQLExecute | None = None |