Fixed #20815 -- Don't enforce unbuffered I/O on Python 3.
No test because this code is already deprecated (part of FastCGI support).
This commit is contained in:
parent
d7f1f316bc
commit
5836a5771f
|
@ -1,6 +1,10 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from . import six
|
||||||
|
|
||||||
|
buffering = int(six.PY3) # No unbuffered text I/O on Python 3 (#20815).
|
||||||
|
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
def become_daemon(our_home_dir='.', out_log='/dev/null',
|
def become_daemon(our_home_dir='.', out_log='/dev/null',
|
||||||
err_log='/dev/null', umask=0o022):
|
err_log='/dev/null', umask=0o022):
|
||||||
|
@ -25,8 +29,8 @@ if os.name == 'posix':
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
si = open('/dev/null', 'r')
|
si = open('/dev/null', 'r')
|
||||||
so = open(out_log, 'a+', 0)
|
so = open(out_log, 'a+', buffering)
|
||||||
se = open(err_log, 'a+', 0)
|
se = open(err_log, 'a+', buffering)
|
||||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||||
os.dup2(se.fileno(), sys.stderr.fileno())
|
os.dup2(se.fileno(), sys.stderr.fileno())
|
||||||
|
@ -44,11 +48,11 @@ else:
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
sys.stderr.close()
|
sys.stderr.close()
|
||||||
if err_log:
|
if err_log:
|
||||||
sys.stderr = open(err_log, 'a', 0)
|
sys.stderr = open(err_log, 'a', buffering)
|
||||||
else:
|
else:
|
||||||
sys.stderr = NullDevice()
|
sys.stderr = NullDevice()
|
||||||
if out_log:
|
if out_log:
|
||||||
sys.stdout = open(out_log, 'a', 0)
|
sys.stdout = open(out_log, 'a', buffering)
|
||||||
else:
|
else:
|
||||||
sys.stdout = NullDevice()
|
sys.stdout = NullDevice()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue