[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ - Collector
#1939: When running as a service, Zope could
Sidnei da Silva
sidnei at enfoldsystems.com
Wed Dec 21 06:34:58 EST 2005
Log message for revision 40942:
- Collector #1939: When running as a service, Zope could
potentially collect too much log output filling the NT Event
Log. When that happened, a 'print' during exception handling
would cause an IOError because the service had no 'redirection
pipe' anymore (because it's shutting down) to write to,
causing the service to not restart automatically.
Changed:
U Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
U Zope/branches/Zope-2_8-branch/lib/python/nt_svcutils/service.py
-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===================================================================
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt 2005-12-21 11:33:04 UTC (rev 40941)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt 2005-12-21 11:34:57 UTC (rev 40942)
@@ -26,6 +26,13 @@
Bugs Fixed
+ - Collector #1939: When running as a service, Zope could
+ potentially collect too much log output filling the NT Event
+ Log. When that happened, a 'print' during exception handling
+ would cause an IOError because the service had no 'redirection
+ pipe' anymore (because it's shutting down) to write to,
+ causing the service to not restart automatically.
+
- Collector #1976: FTP STOR command would load the file being
uploaded in memory. Changed to use a TemporaryFile.
Modified: Zope/branches/Zope-2_8-branch/lib/python/nt_svcutils/service.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/nt_svcutils/service.py 2005-12-21 11:33:04 UTC (rev 40941)
+++ Zope/branches/Zope-2_8-branch/lib/python/nt_svcutils/service.py 2005-12-21 11:34:57 UTC (rev 40942)
@@ -36,8 +36,10 @@
# (except obviously via the event log entry)
# Size of the blocks we read from the child process's output.
CHILDCAPTURE_BLOCK_SIZE = 80
-# The number of BLOCKSIZE blocks we keep as process output.
-CHILDCAPTURE_MAX_BLOCKS = 200
+# The number of BLOCKSIZE blocks we keep as process output. This gives
+# is 4k, which should be enough to see any tracebacks etc, but not so
+# large as to prematurely fill the event log.
+CHILDCAPTURE_MAX_BLOCKS = 50
class Service(win32serviceutil.ServiceFramework):
"""Base class for a Windows Server to manage an external process.
@@ -108,7 +110,10 @@
except win32api.error, details:
# Failed to write a log entry - most likely problem is
# that the event log is full. We don't want this to kill us
- print "FAILED to write INFO event", event, ":", details
+ try:
+ print "FAILED to write INFO event", event, ":", details
+ except IOError:
+ pass
def _dolog(self, func, msg):
try:
@@ -118,8 +123,13 @@
except win32api.error, details:
# Failed to write a log entry - most likely problem is
# that the event log is full. We don't want this to kill us
- print "FAILED to write event log entry:", details
- print msg
+ try:
+ print "FAILED to write event log entry:", details
+ print msg
+ except IOError:
+ # And if running as a service, its likely our sys.stdout
+ # is invalid
+ pass
def info(self, s):
self._dolog(servicemanager.LogInfoMsg, s)
More information about the Zope-Checkins
mailing list