[Zope3-checkins] SVN: Zope3/trunk/ Updated to a version of ZEO that
has a dedicated zeo-client main loop.
Jim Fulton
jim at zope.com
Wed Jul 19 17:39:56 EDT 2006
Log message for revision 69214:
Updated to a version of ZEO that has a dedicated zeo-client main loop.
This means that it is no-longer necessary for Twisted to start a
separate asyncore main loop for ZEO's benefit.
Changed:
U Zope3/trunk/doc/CHANGES.txt
_U Zope3/trunk/src/
D Zope3/trunk/src/zope/app/twisted/asyncore_main_loop.py
U Zope3/trunk/src/zope/app/twisted/main.py
D Zope3/trunk/src/zope/app/twisted/tests/test_asyncore_main_loop.py
U Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2006-07-19 20:53:02 UTC (rev 69213)
+++ Zope3/trunk/doc/CHANGES.txt 2006-07-19 21:39:55 UTC (rev 69214)
@@ -16,6 +16,17 @@
Bug fixes
+ - Fixed issue 650, a test failure on Mac OS X that seemed to
+ indicate deeper problems in ZEO's thread handling. Refactored
+ ZEO so that ZEO clients have their own asyncore loop and don't
+ need two separate networking modes.
+
+ As part of this, some bugs in connection management that
+ weren't tested in asynchronous mode were fixed.
+
+ Added a heart-beat to try to detect lost server connections in
+ situations where such disconnections are not reported by the OS.
+
- Fixed issue 664, apidoc didn't properly handle attributes that
showd up in dir() but that weren't gettable.
Property changes on: Zope3/trunk/src
___________________________________________________________________
Name: svn:externals
- docutils svn://svn.zope.org/repos/main/docutils/tags/0.4.0
ZConfig svn://svn.zope.org/repos/main/ZConfig/trunk/ZConfig
BTrees -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/BTrees
persistent -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/persistent
ThreadedAsync -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ThreadedAsync
transaction -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/transaction
ZEO -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZEO
ZODB -r 68012 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZODB
twisted -r 15340 svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
zdaemon -r 40792 svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon
+ docutils svn://svn.zope.org/repos/main/docutils/tags/0.4.0
ZConfig svn://svn.zope.org/repos/main/ZConfig/trunk/ZConfig
BTrees -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/BTrees
persistent -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/persistent
ThreadedAsync -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ThreadedAsync
transaction -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/transaction
ZEO -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZEO
ZODB -r 69196 svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZODB
twisted -r 15340 svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
zdaemon -r 40792 svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon
Deleted: Zope3/trunk/src/zope/app/twisted/asyncore_main_loop.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/asyncore_main_loop.py 2006-07-19 20:53:02 UTC (rev 69213)
+++ Zope3/trunk/src/zope/app/twisted/asyncore_main_loop.py 2006-07-19 21:39:55 UTC (rev 69214)
@@ -1,117 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Run the asyncore main loop
-
-This module provides a function that tries to run the asyncore main loop.
-
-If the asyncore socket map is empty when the function is called, then the
-function exits immediately:
-
- >>> run(None)
-
-If the loop dies due to an exception, then a panic is logged anf the failure
-handler passed is called:
-
- >>> def failed():
- ... print "FAILED!"
-
- >>> import asyncore
- >>> class BadDispatcher(asyncore.dispatcher):
- ... _fileno = 42
- ... def readable(self):
- ... raise SystemError("I am evil")
-
- >>> import zope.testing.loggingsupport
- >>> handler = zope.testing.loggingsupport.InstalledHandler('ZEO.twisted')
-
- >>> BadDispatcher().add_channel()
-
- >>> run(failed)
- FAILED!
-
- >>> print handler
- ZEO.twisted CRITICAL
- The asyncore main loop died unexpectedly!
-
- >>> print handler.records[0].exc_info[1]
- I am evil
-
-If the handler passed is invalid, another panic will be logged:
-
- >>> run(None)
-
- >>> print handler
- ZEO.twisted CRITICAL
- The asyncore main loop died unexpectedly!
- ZEO.twisted CRITICAL
- The asyncore main loop died unexpectedly!
- ZEO.twisted CRITICAL
- Couldn't call error handler when asyncore main loop died unexpectedly!
-
- >>> print handler.records[-1].exc_info[1]
- 'NoneType' object is not callable
-
-
-$Id$
-"""
-
-import logging
-import sys
-
-# We're using thread, rather than threading because there seem to be
-# some end-of-process cleanup problems with the threading module that
-# cause weird unhelpful messages to get written to standard error
-# intermittently when Python is exiting. We'll leave the old threading
-# code around in case it's helpful later.
-
-## import threading
-import thread
-
-import ThreadedAsync
-logger = logging.getLogger('ZEO.twisted')
-
-def run(onerror):
- try:
- ThreadedAsync.loop()
- except:
- exc_info = sys.exc_info()
- try:
- logger.critical("The asyncore main loop died unexpectedly!",
- exc_info = exc_info,
- )
- try:
- onerror()
- except:
- exc_info = sys.exc_info()
- logger.critical("Couldn't call error handler"
- " when asyncore main loop died unexpectedly!",
- exc_info = exc_info,
- )
- except:
- # Yeah, this is a bare except, but there are reasonable
- # tests for the stuff inside and we need this to prevent spurious
- # errors on shutdown. :(
- pass
-
-def run_in_thread(reactor):
-# see note above
-## thread = threading.Thread(
-## target=run,
-## args=(reactor, ),
-## )
-## thread.setDaemon(True)
-## thread.start()
- thread.start_new_thread(run, (reactor, ))
-
-
Modified: Zope3/trunk/src/zope/app/twisted/main.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/main.py 2006-07-19 20:53:02 UTC (rev 69213)
+++ Zope3/trunk/src/zope/app/twisted/main.py 2006-07-19 21:39:55 UTC (rev 69214)
@@ -33,7 +33,6 @@
import zope.app.appsetup.interfaces
from zope.app import wsgi
from zope.app.twisted import log
-from zope.app.twisted import asyncore_main_loop
CONFIG_FILENAME = "zope.conf"
@@ -85,7 +84,6 @@
global should_restart
should_restart = True
reactor.callFromThread(reactor.stop)
- reactor.callWhenRunning(asyncore_main_loop.run_in_thread, failed)
reactor.run()
Deleted: Zope3/trunk/src/zope/app/twisted/tests/test_asyncore_main_loop.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/tests/test_asyncore_main_loop.py 2006-07-19 20:53:02 UTC (rev 69213)
+++ Zope3/trunk/src/zope/app/twisted/tests/test_asyncore_main_loop.py 2006-07-19 21:39:55 UTC (rev 69214)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""XXX short summary goes here.
-
-$Id$
-"""
-
-import asyncore
-import unittest
-from zope.testing import doctest
-
-def setUp(test):
- test.globs['saved-socket-map'] = asyncore.socket_map.copy()
- asyncore.socket_map.clear()
-
-def tearDown(test):
- test.globs['handler'].uninstall()
- asyncore.socket_map.clear()
- asyncore.socket_map.update(test.globs['saved-socket-map'])
-
-def test_suite():
- return doctest.DocTestSuite('zope.app.twisted.asyncore_main_loop',
- setUp=setUp, tearDown=tearDown)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
-
Modified: Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py 2006-07-19 20:53:02 UTC (rev 69213)
+++ Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py 2006-07-19 21:39:55 UTC (rev 69214)
@@ -14,7 +14,7 @@
r"""Test that ZEO is handled correctly.
This is a rather evil test that involves setting up a real ZEO server
-ans some clients. We'll borrow some evil infrastructure from ZEO to do
+and some clients. We'll borrow some evil infrastructure from ZEO to do
this.
We'll start by setting up and starting a ZEO server.
@@ -262,86 +262,6 @@
f = open(os.path.join(dir, name), 'w')
f.write(template % kw)
f.close()
-
-class BadInstance(Instance):
-
- files = 'runzope', 'site_zcml', 'zope_conf'
-
- def runzope(self):
- template = """
- import sys
- sys.path[:] = %(path)r
- from zope.app.twisted.main import main
- from zope.app.twisted.tests.test_zeo import BadDispatcher
- BadDispatcher().add_channel()
- main(["-C", %(config)r] + sys.argv[1:])
- """
- template = '\n'.join([l.strip() for l in template.split('\n')])
- mkfile(self.dir, "runzope", template, self.__dict__)
-
- def zope_conf(self):
- template = """
- site-definition %(sitezcml)s
- threads 1
- <server>
- type HTTP
- address localhost:%(port)s
- </server>
- <zodb>
- <demostorage>
- </demostorage>
- </zodb>
- <accesslog>
- <logfile>
- path %(accesslog)s
- </logfile>
- </accesslog>
- <eventlog>
- <logfile>
- path %(z3log)s
- </logfile>
- </eventlog>
- """
- mkfile(self.dir, "zope.conf", template, self.__dict__)
-
- def start(self):
- return os.spawnv(os.P_WAIT, sys.executable,
- (sys.executable, '-Wignore',
- os.path.join(self.dir, "runzope"),
- )
- )
-
-class BadDispatcher(asyncore.dispatcher):
- _fileno = 42
- def readable(self):
- raise SystemError("I am evil")
-
-def test_asyncore_failure_causes_zope_failure():
- """
-
-A failure of the asyncore mail loop should cause a zope process to fail:
-
- >>> bad = BadInstance()
- >>> bad.start()
- 1
-
-And puts a panic in the event log:
-
- >>> print open(bad.z3log).read()
- ------
- ... CRITICAL ZEO.twisted The asyncore main loop died unexpectedly!
- Traceback (most recent call last):
- ...
- raise SystemError("I am evil")
- SystemError: I am evil
- <BLANKLINE>
-
-
-Cleanup:
-
- >>> shutil.rmtree(bad.dir)
-
-"""
def test_suite():
suite = doctest.DocTestSuite(
More information about the Zope3-Checkins
mailing list