MCPcopy
hub / github.com/celery/celery / on_worker_process_init

Method on_worker_process_init

celery/fixups/django.py:165–185  ·  view source on GitHub ↗
(self, **kwargs: Any)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 5

validate_modelsMethod · 0.95
_maybe_close_db_fdMethod · 0.95
_close_databaseMethod · 0.95
close_cacheMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected