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

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


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

Modified Files:
      Tag: Zope-2_6-branch
	z2.py 
Log Message:
Merged shane-fix-startup-branch.  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.83.2.2 => 1.83.2.3 ===
--- Zope/z2.py:1.83.2.2	Tue Oct  8 17:18:20 2002
+++ Zope/z2.py	Tue Oct 22 10:15:30 2002
@@ -577,7 +577,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