MCPcopy
hub / github.com/benoitc/gunicorn / _cleanup

Method _cleanup

gunicorn/dirty/worker.py:502–530  ·  view source on GitHub ↗

Clean up resources on shutdown.

(self)

Source from the content-addressed store, hash-verified

500 )
501
502 def _cleanup(self):
503 """Clean up resources on shutdown."""
504 # Shutdown thread pool executor
505 if self._executor:
506 self._executor.shutdown(wait=False, cancel_futures=True)
507 self._executor = None
508
509 # Close all apps
510 for path, app in self.apps.items():
511 try:
512 app.close()
513 self.log.debug("Closed dirty app: %s", path)
514 except Exception as e:
515 self.log.error("Error closing dirty app %s: %s", path, e)
516
517 # Close temp file
518 try:
519 self.tmp.close()
520 except Exception:
521 pass
522
523 # Remove socket file
524 try:
525 if os.path.exists(self.socket_path):
526 os.unlink(self.socket_path)
527 except Exception:
528 pass
529
530 self.log.info("Dirty worker %s exiting", self.pid)

Calls 8

itemsMethod · 0.80
existsMethod · 0.80
unlinkMethod · 0.80
shutdownMethod · 0.45
closeMethod · 0.45
debugMethod · 0.45
errorMethod · 0.45
infoMethod · 0.45