[Zope-Checkins] CVS: Zope/lib/python/Zope - __init__.py:1.23.26.1

Chris McDonough chrism@zope.com
Sun, 30 Sep 2001 03:08:25 -0400


Update of /cvs-repository/Zope/lib/python/Zope
In directory cvs.zope.org:/tmp/cvs-serv6748/lib/python/Zope

Modified Files:
      Tag: chrism-setrlimit-branch
	__init__.py 
Log Message:
Make necessary changes to be able to specify rlimit of mem size on command line at start time.


=== Zope/lib/python/Zope/__init__.py 1.23 => 1.23.26.1 ===
 import ZODB.POSException, ZPublisher, string, ZPublisher
 import ExtensionClass
-from zLOG import LOG, INFO, WARNING
+from zLOG import LOG, INFO, WARNING, PANIC
 
 def debug(*args, **kw):
     return apply(ZPublisher.test,('Zope',)+args, kw)
@@ -167,12 +167,16 @@
 class RequestContainer(ExtensionClass.Base):
         def __init__(self,r): self.REQUEST=r
 
+memory_errcls = 'Zope'
+memory_errmsg = "Out of free memory, restarting!"
+
 def zpublisher_exception_hook(
     published, REQUEST, t, v, traceback,
     # static
     StringType=type(''),
     lower=string.lower,
     ConflictError=ZODB.POSException.ConflictError,
+    MemoryError=MemoryError,
     ListType=type([]),
     ):
     try:
@@ -180,6 +184,9 @@
              lower(t) in ('unauthorized', 'redirect'))
             or t is SystemExit):
             raise
+        if t is MemoryError:
+            LOG(memory_errcls, PANIC, memory_errmsg)
+            sys.exit(memory_errmsg)
         if t is ConflictError:
             # now what
             # First, we need to close the current connection. We'll