Skip to content

Commit

Permalink
fix workers relaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Chesneau committed Jan 16, 2010
1 parent 9900371 commit ecd684e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
13 changes: 7 additions & 6 deletions gunicorn/arbiter.py
Expand Up @@ -126,20 +126,24 @@ def init_socket(self, address):
sock.listen(2048)
return sock

def set_sockopts(self, sock):
def set_sockopts(self, sock):

sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0)
if hasattr(socket, "TCP_CORK"):
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_CORK, 1)
elif hasattr(socket, "TCP_NOPUSH"):
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NOPUSH, 1)

def run(self):
self.manage_workers()
while True:
try:
sig = self.SIG_QUEUE.pop(0) if len(self.SIG_QUEUE) else None
if sig is None:
self.murder_workers()
self.reap_workers()
self.manage_workers()
self.sleep()
continue

Expand All @@ -155,9 +159,6 @@ def run(self):
log.info("Handling signal: %s" % signame)
handler()

self.murder_workers()
self.reap_workers()
self.manage_workers()
except StopIteration:
break
except KeyboardInterrupt:
Expand Down
4 changes: 1 addition & 3 deletions gunicorn/http/request.py
Expand Up @@ -69,13 +69,11 @@ def read(self):
remain = CHUNK_SIZE
buf = create_string_buffer(remain)
remain -= self.socket.recv_into(buf, remain)

while not self.parser.headers(headers, buf):
data = create_string_buffer(remain)
remain -= self.socket.recv_into(data, remain)
buf = create_string_buffer(data.value + buf.value)

print headers

if headers.get('Except', '').lower() == "100-continue":
self.socket.send("100 Continue\n")

Expand Down
2 changes: 0 additions & 2 deletions gunicorn/http/response.py
Expand Up @@ -53,11 +53,9 @@ def send(self):

self.sock.send("%s\r\n" % "".join(resp_head))


for chunk in self.data:
self.sock.send(chunk)

print "sent"
self.sock.close()

if hasattr(self.data, "close"):
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/util.py
Expand Up @@ -26,7 +26,7 @@

import time

CHUNK_SIZE = 16 * 1024
CHUNK_SIZE = (16 * 1024)

MAX_BODY = 1024 * (80 + 32)

Expand Down
5 changes: 0 additions & 5 deletions gunicorn/worker.py
Expand Up @@ -102,24 +102,19 @@ def run(self):
except select.error, e:
if e[0] == errno.EINTR:
break
elif e[0] == errno.EBADF:
return
raise


# Accept until we hit EAGAIN. We're betting that when we're
# processing clients that more clients are waiting. When
# there's no more clients waiting we go back to the select()
# loop and wait for some lovin.
while self.alive:
try:

conn, addr = self.socket.accept()
conn.setblocking(1)

# handle connection
self.handle(conn, addr)


# Update the fd mtime on each client completion
# to signal that this worker process is alive.
Expand Down

0 comments on commit ecd684e

Please sign in to comment.