[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - DualModeChannel.py:1.1.2.3 HTTPServer.py:1.1.2.17 ServerBase.py:1.1.2.3
Shane Hathaway
shane@cvs.zope.org
Mon, 1 Apr 2002 14:10:51 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv25239
Modified Files:
Tag: Zope-3x-branch
DualModeChannel.py HTTPServer.py ServerBase.py
Log Message:
Changed some method names and added comments for clarity.
=== Zope3/lib/python/Zope/Server/DualModeChannel.py 1.1.2.2 => 1.1.2.3 ===
asyncore.dispatcher.__init__(self, conn)
- def get_sync_streams(self):
- return synchronous_streams(self)
-
#
# ASYNCHRONOUS METHODS
#
@@ -157,7 +154,7 @@
# SYNCHRONOUS METHODS
#
- def sync_write(self, data):
+ def write(self, data):
if data:
self.outbuf.append(data)
while len(self.outbuf) >= self.adj.send_bytes:
@@ -167,7 +164,7 @@
if not self._flush_some():
break
- def sync_flush(self):
+ def flush(self):
"""
Pauses the application while outbuf is flushed.
Normally not a good thing to do.
@@ -277,17 +274,17 @@
# SYNCHRONOUS METHODS
#
- def sync_write(self, data):
+ def write(self, data):
self._writelock_acquire()
try:
- DualModeChannel.sync_write(self, data)
+ DualModeChannel.write(self, data)
finally:
self._writelock_release()
- def sync_flush(self):
+ def flush(self):
self._writelock_acquire()
try:
- DualModeChannel.sync_flush(self)
+ DualModeChannel.flush(self)
finally:
self._writelock_release()
=== Zope3/lib/python/Zope/Server/HTTPServer.py 1.1.2.16 => 1.1.2.17 ===
if not self.wrote_header:
rh = self.buildResponseHeader()
- channel.sync_write(rh)
+ channel.write(rh)
self.bytes_written += len(rh)
self.wrote_header = 1
if data:
- channel.sync_write(data)
+ channel.write(data)
self.bytes_written += len(data)
def flush(self):
- self.channel.sync_flush()
+ self.channel.flush()
=== Zope3/lib/python/Zope/Server/ServerBase.py 1.1.2.2 => 1.1.2.3 ===
ready_requests = None # A list
last_activity = 0 # Time of last activity
- running_tasks = 0 # boolean
+ running_tasks = 0 # boolean: true when any task is being executed
#
# ASYNCHRONOUS METHODS (incl. __init__)
@@ -152,7 +152,7 @@
data = data[n:]
def queue_request(self, req):
- """Queues a request to be processed in sequence by a task.
+ """Queues a request to be processed in sequence.
"""
do_now = 0
running_lock.acquire()
@@ -171,8 +171,7 @@
finally:
running_lock.release()
if do_now:
- self.set_sync()
- self.create_task(req)
+ self.process_request(req)
def handle_error(self):
"""Handles program errors (not communication errors)
@@ -196,7 +195,7 @@
#
def end_task(self, close):
- """Called at the end of a task, may launch another task.
+ """Called at the end of a task and may launch another task.
"""
if close:
self.close_when_done()
@@ -208,12 +207,13 @@
if rr:
new_req = rr.pop(0)
else:
+ # No requests to service.
self.running_tasks = 0
finally:
running_lock.release()
if new_req:
# Respond to the next request.
- self.create_task(new_req)
+ self.process_request(new_req)
else:
# Wait for another request on this connection.
self.set_async()
@@ -222,11 +222,12 @@
# BOTH MODES
#
- def create_task(self, req):
+ def process_request(self, req):
"""Creates a new task and queues it for execution.
The task may get executed in another thread.
"""
+ self.set_sync()
task = self.task_class(self, req)
self.server.addTask(task)