(self, **kwargs: Any)
| 163 | return self |
| 164 | |
| 165 | def on_worker_process_init(self, **kwargs: Any) -> None: |
| 166 | # Child process must validate models again if on Windows, |
| 167 | # or if they were started using execv. |
| 168 | if os.environ.get('FORKED_BY_MULTIPROCESSING'): |
| 169 | self.validate_models() |
| 170 | |
| 171 | # close connections: |
| 172 | # the parent process may have established these, |
| 173 | # so need to close them. |
| 174 | |
| 175 | # calling db.close() on some DB connections will cause |
| 176 | # the inherited DB conn to also get broken in the parent |
| 177 | # process so we need to remove it without triggering any |
| 178 | # network IO that close() might cause. |
| 179 | for c in self._db.connections.all(): |
| 180 | if c and c.connection: |
| 181 | self._maybe_close_db_fd(c) |
| 182 | |
| 183 | # use the _ version to avoid DB_REUSE preventing the conn.close() call |
| 184 | self._close_database() |
| 185 | self.close_cache() |
| 186 | |
| 187 | def _maybe_close_db_fd(self, c: "BaseDatabaseWrapper") -> None: |
| 188 | try: |
nothing calls this directly
no test coverage detected