Commit 6764040e authored by Sidnei da Silva's avatar Sidnei da Silva

- 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 in the restart code causing the service
        not to restart automatically.

        Problem is that a service/pythonw.exe process *always* has an
        invalid sys.stdout.  But due to the magic of buffering, small
        print statements would not fail - but once the file actually
        got written to, the error happened.  Never a problem when
        debugging, as the process has a console, and hence a valid
        stdout.
parent dacf46c1
...@@ -124,6 +124,19 @@ Zope Changes ...@@ -124,6 +124,19 @@ Zope Changes
Bugs Fixed 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 in the restart code causing the service
not to restart automatically.
Problem is that a service/pythonw.exe process *always* has an
invalid sys.stdout. But due to the magic of buffering, small
"print" statements would not fail - but once the file actually
got written to, the error happened. Never a problem when
debugging, as the process has a console, and hence a valid
stdout.
- For content-type HTTP headers starting with 'text/' or 'application/' - For content-type HTTP headers starting with 'text/' or 'application/'
the 'charset' field is automatically if not specified by the the 'charset' field is automatically if not specified by the
application. The 'charset' is determined by the content-type header application. The 'charset' is determined by the content-type header
......
...@@ -36,8 +36,10 @@ BACKOFF_INITIAL_INTERVAL = 5 ...@@ -36,8 +36,10 @@ BACKOFF_INITIAL_INTERVAL = 5
# (except obviously via the event log entry) # (except obviously via the event log entry)
# Size of the blocks we read from the child process's output. # Size of the blocks we read from the child process's output.
CHILDCAPTURE_BLOCK_SIZE = 80 CHILDCAPTURE_BLOCK_SIZE = 80
# The number of BLOCKSIZE blocks we keep as process output. # The number of BLOCKSIZE blocks we keep as process output. This gives
CHILDCAPTURE_MAX_BLOCKS = 200 # 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): class Service(win32serviceutil.ServiceFramework):
"""Base class for a Windows Server to manage an external process. """Base class for a Windows Server to manage an external process.
...@@ -108,7 +110,10 @@ class Service(win32serviceutil.ServiceFramework): ...@@ -108,7 +110,10 @@ class Service(win32serviceutil.ServiceFramework):
except win32api.error, details: except win32api.error, details:
# Failed to write a log entry - most likely problem is # Failed to write a log entry - most likely problem is
# that the event log is full. We don't want this to kill us # that the event log is full. We don't want this to kill us
try:
print "FAILED to write INFO event", event, ":", details print "FAILED to write INFO event", event, ":", details
except IOError:
pass
def _dolog(self, func, msg): def _dolog(self, func, msg):
try: try:
...@@ -118,8 +123,13 @@ class Service(win32serviceutil.ServiceFramework): ...@@ -118,8 +123,13 @@ class Service(win32serviceutil.ServiceFramework):
except win32api.error, details: except win32api.error, details:
# Failed to write a log entry - most likely problem is # Failed to write a log entry - most likely problem is
# that the event log is full. We don't want this to kill us # that the event log is full. We don't want this to kill us
try:
print "FAILED to write event log entry:", details print "FAILED to write event log entry:", details
print msg print msg
except IOError:
# And if running as a service, its likely our sys.stdout
# is invalid
pass
def info(self, s): def info(self, s):
self._dolog(servicemanager.LogInfoMsg, s) self._dolog(servicemanager.LogInfoMsg, s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment