diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 3109b7654..03508872f 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -548,14 +548,15 @@ def spawn_worker(self): self.cfg.pre_fork(self, worker) pid = os.fork() if pid != 0: + worker.pid = pid self.WORKERS[pid] = worker return pid # Process Child - worker_pid = os.getpid() + worker.pid = os.getpid() try: util._setproctitle("worker [%s]" % self.proc_name) - self.log.info("Booting worker with pid: %s", worker_pid) + self.log.info("Booting worker with pid: %s", worker.pid) self.cfg.post_fork(self, worker) worker.init_process() sys.exit(0) @@ -573,7 +574,7 @@ def spawn_worker(self): sys.exit(self.WORKER_BOOT_ERROR) sys.exit(-1) finally: - self.log.info("Worker exiting (pid: %s)", worker_pid) + self.log.info("Worker exiting (pid: %s)", worker.pid) try: worker.tmp.close() self.cfg.worker_exit(self, worker) diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index fd259461a..94e7c5674 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -38,6 +38,7 @@ def __init__(self, age, ppid, sockets, app, timeout, cfg, log): changes you'll want to do that in ``self.init_process()``. """ self.age = age + self.pid = "[booting]" self.ppid = ppid self.sockets = sockets self.app = app @@ -57,10 +58,6 @@ def __init__(self, age, ppid, sockets, app, timeout, cfg, log): def __str__(self): return "" % self.pid - @property - def pid(self): - return os.getpid() - def notify(self): """\ Your worker subclass must arrange to have this method called