diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 6e251dca..e6690983 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -400,14 +400,10 @@ class Arbiter(object): This is where a worker process leaves the main loop of the master process. """ - workers = set(w.id for w in self.WORKERS.values()) - for i in range(self.num_workers): - if i in workers: - continue - + + for i in range(self.num_workers - len(self.WORKERS.keys())): self.worker_age += 1 - worker = Worker(i, self.worker_age, self.pid, - self.LISTENER, self.app, + worker = Worker(self.worker_age, self.pid, self.LISTENER, self.app, self.timeout/2.0, self.conf) self.conf.before_fork(self, worker) pid = os.fork() @@ -420,7 +416,7 @@ class Arbiter(object): try: util._setproctitle("worker [%s]" % self.proc_name) self.log.debug("Booting worker: %s (age: %s)" % ( - i, self.worker_age)) + worker_pid, self.worker_age)) self.conf.after_fork(self, worker) worker.run() sys.exit(0) @@ -430,7 +426,7 @@ class Arbiter(object): self.log.exception("Exception in worker process.") sys.exit(-1) finally: - self.log.info("Worker exiting: %s (pid: %s)" % (i, worker_pid)) + self.log.info("Worker exiting (pid: %s)" % worker_pid) try: worker.tmp.close() os.unlink(worker.tmpname) diff --git a/gunicorn/config.py b/gunicorn/config.py index ad13599f..12b318be 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -27,7 +27,7 @@ class Config(object): group=None, after_fork=lambda server, worker: server.log.info( - "Worker spawned: %s (pid: %s)" % (worker.id, worker.pid)), + "Worker spawned (pid: %s)" % worker.pid), before_fork=lambda server, worker: True, diff --git a/gunicorn/worker.py b/gunicorn/worker.py index a2bfcebc..dd3dd485 100644 --- a/gunicorn/worker.py +++ b/gunicorn/worker.py @@ -27,9 +27,8 @@ class Worker(object): PIPE = [] - def __init__(self, workerid, age, ppid, socket, app, timeout, conf): + def __init__(self, age, ppid, socket, app, timeout, conf): self.nr = 0 - self.id = workerid self.age = age self.ppid = ppid self.debug = conf['debug'] @@ -46,7 +45,7 @@ class Worker(object): self.address = self.socket.getsockname() def __str__(self): - return "" % self.id + return "" % os.getpid() @property def pid(self):