[Zodb-checkins] SVN: ZODB/trunk/src/ Removed ThreadedAsync and
(last?) vestiges of the old "non-async"
Jim Fulton
jim at zope.com
Mon Feb 18 06:32:30 EST 2008
Log message for revision 84017:
Removed ThreadedAsync and (last?) vestiges of the old "non-async"
mode.
Changed:
U ZODB/trunk/src/CHANGES.txt
D ZODB/trunk/src/ThreadedAsync/
U ZODB/trunk/src/ZEO/ClientStorage.py
U ZODB/trunk/src/ZEO/runzeo.py
U ZODB/trunk/src/ZEO/tests/zeoserver.py
U ZODB/trunk/src/ZEO/zrpc/connection.py
U ZODB/trunk/src/ZEO/zrpc/server.py
U ZODB/trunk/src/ZODB/scripts/zodbload.py
-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/CHANGES.txt 2008-02-18 11:32:30 UTC (rev 84017)
@@ -32,6 +32,8 @@
on datetimes or serials (TIDs). See
src/ZODB/historical_connections.txt.
+- Removed the ThreadedAsync module.
+
Bugs Fixed
----------
Modified: ZODB/trunk/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/trunk/src/ZEO/ClientStorage.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZEO/ClientStorage.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -369,7 +369,6 @@
# still be going on. This code must wait until validation
# finishes, but if the connection isn't a zrpc async
# connection it also needs to poll for input.
- assert self._connection.is_async()
while 1:
self._ready.wait(30)
if self._ready.isSet():
@@ -524,8 +523,6 @@
# handled in order.
self._info.update(stub.get_info())
- assert conn.is_async()
-
self._handle_extensions()
def _handle_extensions(self):
Modified: ZODB/trunk/src/ZEO/runzeo.py
===================================================================
--- ZODB/trunk/src/ZEO/runzeo.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZEO/runzeo.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -34,6 +34,7 @@
# For the forseeable future, it must work under Python 2.1 as well as
# 2.2 and above.
+import asyncore
import os
import sys
import signal
@@ -241,8 +242,7 @@
auth_realm=self.options.auth_realm)
def loop_forever(self):
- import ThreadedAsync.LoopCallback
- ThreadedAsync.LoopCallback.loop()
+ asyncore.loop()
def handle_sigterm(self):
log("terminated by SIGTERM")
Modified: ZODB/trunk/src/ZEO/tests/zeoserver.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/zeoserver.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZEO/tests/zeoserver.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -13,6 +13,7 @@
##############################################################################
"""Helper file used to launch a ZEO server cross platform"""
+import asyncore
import os
import sys
import time
@@ -24,8 +25,6 @@
import threading
import logging
-import ThreadedAsync.LoopCallback
-
from ZEO.StorageServer import StorageServer
from ZEO.runzeo import ZEOOptions
@@ -208,8 +207,8 @@
d.setDaemon(1)
d.start()
# Loop for socket events
- log(label, 'entering ThreadedAsync loop')
- ThreadedAsync.LoopCallback.loop()
+ log(label, 'entering asyncore loop')
+ asyncore.loop()
if __name__ == '__main__':
Modified: ZODB/trunk/src/ZEO/zrpc/connection.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/connection.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZEO/zrpc/connection.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -21,7 +21,6 @@
import traceback, time
-import ThreadedAsync
from ZEO.zrpc import smac
from ZEO.zrpc.error import ZRPCError, DisconnectedError
from ZEO.zrpc.marshal import Marshaller
@@ -383,15 +382,7 @@
ourmap = {}
self.__super_init(sock, addr, map=ourmap)
- # A Connection either uses asyncore directly or relies on an
- # asyncore mainloop running in a separate thread. If
- # thr_async is true, then the mainloop is running in a
- # separate thread. If thr_async is true, then the asyncore
- # trigger (self.trigger) is used to notify that thread of
- # activity on the current thread.
- self.thr_async = False
- self.trigger = None
- self._prepare_async()
+ self.trigger = trigger()
# The singleton dict is used in synchronous mode when a method
# needs to call into asyncore to try to force some I/O to occur.
@@ -684,10 +675,7 @@
if self.closed:
raise DisconnectedError()
msgid = self.send_call(method, args, 0)
- if self.is_async():
- self.trigger.pull_trigger()
- else:
- asyncore.poll(0.01, self._singleton)
+ self.trigger.pull_trigger()
return msgid
def _deferred_wait(self, msgid):
@@ -728,23 +716,6 @@
# handle IO, possibly in async mode
- def _prepare_async(self):
- self.thr_async = False
- ThreadedAsync.register_loop_callback(self.set_async)
- # TODO: If we are not in async mode, this will cause dead
- # Connections to be leaked.
-
- def set_async(self, map):
- self.trigger = trigger()
- self.thr_async = True
-
- def is_async(self):
- # Overridden by ManagedConnection
- if self.thr_async:
- return 1
- else:
- return 0
-
def _pull_trigger(self, tryagain=10):
try:
self.trigger.pull_trigger()
@@ -757,11 +728,10 @@
def wait(self, msgid):
"""Invoke asyncore mainloop and wait for reply."""
if __debug__:
- self.log("wait(%d), async=%d" % (msgid, self.is_async()),
- level=TRACE)
- if self.is_async():
- self._pull_trigger()
+ self.log("wait(%d)" % msgid, level=TRACE)
+ self._pull_trigger()
+
# Delay used when we call asyncore.poll() directly.
# Start with a 1 msec delay, double until 1 sec.
delay = 0.001
@@ -778,7 +748,6 @@
self.log("wait(%d): reply=%s" %
(msgid, short_repr(reply)), level=TRACE)
return reply
- assert self.is_async() # XXX we're such cowards
self.replies_cond.wait()
finally:
self.replies_cond.release()
@@ -793,65 +762,9 @@
def poll(self):
"""Invoke asyncore mainloop to get pending message out."""
if __debug__:
- self.log("poll(), async=%d" % self.is_async(), level=TRACE)
- if self.is_async():
- self._pull_trigger()
- else:
- asyncore.poll(0.0, self._singleton)
-
- def _pending(self, timeout=0):
- """Invoke mainloop until any pending messages are handled."""
- if __debug__:
- self.log("pending(), async=%d" % self.is_async(), level=TRACE)
- if self.is_async():
- return
- # Inline the asyncore poll() function to know whether any input
- # was actually read. Repeat until no input is ready.
-
- # Pending does reads and writes. In the case of server
- # startup, we may need to write out zeoVerify() messages.
- # Always check for read status, but don't check for write status
- # only there is output to do. Only continue in this loop as
- # long as there is data to read.
- r = r_in = [self._fileno]
- x_in = []
- while r and not self.closed:
- if self.writable():
- w_in = [self._fileno]
- else:
- w_in = []
- try:
- r, w, x = select.select(r_in, w_in, x_in, timeout)
- except select.error, err:
- if err[0] == errno.EINTR:
- timeout = 0
- continue
- else:
- raise
- else:
- # Make sure any subsequent select does not block. The
- # loop is only intended to make sure all incoming data is
- # returned.
-
- # Insecurity: What if the server sends a lot of
- # invalidations, such that pending never finishes? Seems
- # unlikely, but possible.
- timeout = 0
- if r:
- try:
- self.handle_read_event()
- except asyncore.ExitNow:
- raise
- except:
- self.handle_error()
- if w:
- try:
- self.handle_write_event()
- except asyncore.ExitNow:
- raise
- except:
- self.handle_error()
-
+ self.log("poll()", level=TRACE)
+ self._pull_trigger()
+
class ManagedServerConnection(Connection):
"""Server-side Connection subclass."""
__super_init = Connection.__init__
@@ -895,7 +808,6 @@
self.queued_messages = []
self.__super_init(sock, addr, obj, tag='C', map=client_map)
- self.thr_async = True
self.trigger = client_trigger
client_trigger.pull_trigger()
@@ -951,16 +863,6 @@
# we're closed.
self.trigger.pull_trigger()
- def set_async(self, map):
- pass
-
- def _prepare_async(self):
- # Don't do the register_loop_callback that the superclass does
- pass
-
- def is_async(self):
- return True
-
def close(self):
self.mgr.close_conn(self)
self.__super_close()
Modified: ZODB/trunk/src/ZEO/zrpc/server.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/server.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZEO/zrpc/server.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -18,10 +18,9 @@
from ZEO.zrpc.connection import Connection
from ZEO.zrpc.log import log
import logging
-import ThreadedAsync.LoopCallback
# Export the main asyncore loop
-loop = ThreadedAsync.LoopCallback.loop
+loop = asyncore.loop
class Dispatcher(asyncore.dispatcher):
"""A server that accepts incoming RPC connections"""
Modified: ZODB/trunk/src/ZODB/scripts/zodbload.py
===================================================================
--- ZODB/trunk/src/ZODB/scripts/zodbload.py 2008-02-18 11:25:48 UTC (rev 84016)
+++ ZODB/trunk/src/ZODB/scripts/zodbload.py 2008-02-18 11:32:30 UTC (rev 84017)
@@ -790,9 +790,6 @@
import Zope2
Zope2.startup()
- #from ThreadedAsync.LoopCallback import loop
- #threading.Thread(target=loop, args=(), name='asyncore').start()
-
jobs = JobProducer()
for job, kw, frequency, sleep, repeatp in jobdefs:
Job = globals()[job.capitalize()+'Job']
More information about the Zodb-checkins
mailing list