[Zope-Checkins] CVS: Zope - z2.py:1.87

Shane Hathaway shane@zope.com
Tue, 22 Oct 2002 10:24:07 -0400


Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv27305

Modified Files:
	z2.py 
Log Message:
Merged shane-fix-startup-branch to HEAD.  Summary:

Delayed Zope startup based on changes from Zope-2_7-development-branch
(with corrections), with the intent of merging this into the 2_6
branch and the head.

Until now, "import Zope" always opened the database automatically.
Unfortunately, that strategy caused the Python import lock to be held
by the main thread during database initialization, which led to a
deadlock if other threads required something to be imported before
completing initialization.  This can be a big problem for ZEO.

The only foreseen risk is that external scripts which "import Zope"
may depend in some way on the database being opened immediately.  Most
scripts just use "Zope.app()", which still works well.  If you have a
script that breaks with these changes, either add a call to the new
Zope.startup() function or set the ZOPE_COMPATIBLE_STARTUP environment
variable to a non-empty value.


=== Zope/z2.py 1.86 => 1.87 ===
--- Zope/z2.py:1.86	Wed Oct  9 14:44:18 2002
+++ Zope/z2.py	Tue Oct 22 10:23:36 2002
@@ -576,7 +576,11 @@
         sys.__detailedlog=DL
 
     # Import Zope (or Main)
-    exec "import "+MODULE in {}
+    if MODULE == 'Zope':
+        import Zope
+        Zope.startup()
+    else:
+        exec "import "+MODULE in {}
 
     # Location of the ZServer log file. This file logs all ZServer activity.
     # You may wish to create different logs for different servers. See