self.alive is'nt anymore a file descriptor

This commit is contained in:
Benoit Chesneau 2010-01-10 11:37:18 +01:00
parent 004f441d59
commit 7cf859a5c0
2 changed files with 7 additions and 6 deletions

View File

@ -246,8 +246,9 @@ class Arbiter(object):
continue continue
# Process Child # Process Child
worker_pid = os.getpid()
try: try:
log.info("Worker %s booting" % os.getpid()) log.info("Worker %s booting" % worker_pid)
worker.run() worker.run()
sys.exit(0) sys.exit(0)
except SystemExit: except SystemExit:
@ -256,7 +257,8 @@ class Arbiter(object):
log.exception("Exception in worker process.") log.exception("Exception in worker process.")
sys.exit(-1) sys.exit(-1)
finally: finally:
log.info("Worker %s exiting." % os.getpid()) worker.tmp.close()
log.info("Worker %s exiting." % worker_pid)
def kill_workers(self, sig): def kill_workers(self, sig):
for pid in self.WORKERS.keys(): for pid in self.WORKERS.keys():

View File

@ -46,7 +46,6 @@ class Worker(object):
) )
def __init__(self, workerid, ppid, socket, app): def __init__(self, workerid, ppid, socket, app):
self.id = workerid self.id = workerid
self.ppid = ppid self.ppid = ppid
self.socket = socket self.socket = socket
@ -72,7 +71,7 @@ class Worker(object):
spinner = 0 spinner = 0
while self.alive: while self.alive:
spinner = (spinner+1) % 2 spinner = (spinner+1) % 2
os.fchmod(self.alive, spinner) os.fchmod(self.tmp.fileno(), spinner)
while self.alive: while self.alive:
try: try:
@ -105,7 +104,7 @@ class Worker(object):
# Update the fd mtime on each client completion # Update the fd mtime on each client completion
# to signal that this worker process is alive. # to signal that this worker process is alive.
spinner = (spinner+1) % 2 spinner = (spinner+1) % 2
os.fchmod(self.alive, spinner) os.fchmod(self.tmp.fileno(), spinner)
def handle(self, conn, client): def handle(self, conn, client):
req = http.HTTPRequest(conn, client, self.address) req = http.HTTPRequest(conn, client, self.address)