From 10ccfbbf3c1fd84a22d55cde63e573cb178872b5 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 1 Nov 2019 22:18:32 +0100 Subject: [PATCH] Remove early return in upkeep() in case sys.stdout is replaced. We don't want flushing to be entirely skipped just because of that. --- src/world.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/world.py b/src/world.py index 1911383e0..eec3b3e65 100644 --- a/src/world.py +++ b/src/world.py @@ -154,19 +154,19 @@ def upkeep(): if not hasattr(sys.stdout, 'getvalue'): # Stupid twisted sometimes replaces our stdout with theirs, because # "The Twisted Way Is The Right Way" (ha!). So we're stuck simply - # returning. + # skipping the checks log.warning('Expected cStringIO as stdout, got %r.', sys.stdout) - return - s = sys.stdout.getvalue() - if s: - log.warning('Printed to stdout after daemonization: %s', s) - sys.stdout.seek(0) - sys.stdout.truncate() # Truncates to current offset. - s = sys.stderr.getvalue() - if s: - log.error('Printed to stderr after daemonization: %s', s) - sys.stderr.seek(0) - sys.stderr.truncate() # Truncates to current offset. + else: + s = sys.stdout.getvalue() + if s: + log.warning('Printed to stdout after daemonization: %s', s) + sys.stdout.seek(0) + sys.stdout.truncate() # Truncates to current offset. + s = sys.stderr.getvalue() + if s: + log.error('Printed to stderr after daemonization: %s', s) + sys.stderr.seek(0) + sys.stderr.truncate() # Truncates to current offset. doFlush = conf.supybot.flush() and not starting if doFlush: flush()