Commit 6a5dfc32 authored by Sidnei da Silva's avatar Sidnei da Silva

- Temporary workaround for new asyncore in Python 2.6. Need to clean this up

parent 4913d686
...@@ -45,7 +45,8 @@ from HTTPResponse import make_response ...@@ -45,7 +45,8 @@ from HTTPResponse import make_response
from ZPublisher.HTTPRequest import HTTPRequest from ZPublisher.HTTPRequest import HTTPRequest
from App.config import getConfiguration from App.config import getConfiguration
from medusa.http_server import http_server,get_header, http_channel, VERSION_STRING from medusa.http_server import http_server, get_header
from medusa.http_server import fifo, http_channel, VERSION_STRING
import asyncore import asyncore
from medusa import counter, producers from medusa import counter, producers
from medusa.test import max_sockets from medusa.test import max_sockets
...@@ -334,6 +335,10 @@ class zhttp_channel(http_channel): ...@@ -334,6 +335,10 @@ class zhttp_channel(http_channel):
def __init__(self, server, conn, addr): def __init__(self, server, conn, addr):
http_channel.__init__(self, server, conn, addr) http_channel.__init__(self, server, conn, addr)
if isinstance(self.producer_fifo, fifo):
self.producer_fifo_push = self.producer_fifo.push
else:
self.producer_fifo_push = self.producer_fifo.append
requestCloseOnExec(conn) requestCloseOnExec(conn)
self.queue=[] self.queue=[]
self.working=0 self.working=0
...@@ -345,7 +350,7 @@ class zhttp_channel(http_channel): ...@@ -345,7 +350,7 @@ class zhttp_channel(http_channel):
# producers by default # producers by default
if self.closed: if self.closed:
return return
self.producer_fifo.push(producer) self.producer_fifo_push(producer)
if send: self.initiate_send() if send: self.initiate_send()
push_with_producer=push push_with_producer=push
......
...@@ -528,25 +528,25 @@ class http_channel (asynchat.async_chat): ...@@ -528,25 +528,25 @@ class http_channel (asynchat.async_chat):
# no handlers, so complain # no handlers, so complain
r.error (404) r.error (404)
def writable (self): #def writable (self):
# this is just the normal async_chat 'writable', here for comparison # # this is just the normal async_chat 'writable', here for comparison
return self.ac_out_buffer or len(self.producer_fifo) # return self.ac_out_buffer or len(self.producer_fifo)
def writable_for_proxy (self): #def writable_for_proxy (self):
# this version of writable supports the idea of a 'stalled' producer # # this version of writable supports the idea of a 'stalled' producer
# [i.e., it's not ready to produce any output yet] This is needed by # # [i.e., it's not ready to produce any output yet] This is needed by
# the proxy, which will be waiting for the magic combination of # # the proxy, which will be waiting for the magic combination of
# 1) hostname resolved # # 1) hostname resolved
# 2) connection made # # 2) connection made
# 3) data available. # # 3) data available.
if self.ac_out_buffer: # if self.ac_out_buffer:
return 1 # return 1
elif len(self.producer_fifo): # elif len(self.producer_fifo):
p = self.producer_fifo.first() # p = self.producer_fifo.first()
if hasattr (p, 'stalled'): # if hasattr (p, 'stalled'):
return not p.stalled() # return not p.stalled()
else: # else:
return 1 # return 1
# =========================================================================== # ===========================================================================
# HTTP Server Object # HTTP Server Object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment