mirror of https://github.com/python/cpython.git
Fix from Vinaj for the "writing to closed file" errors. SF 670390.
This commit is contained in:
parent
81d40d6f47
commit
2a1d51602b
|
@ -1,5 +1,4 @@
|
||||||
test_logging
|
test_logging
|
||||||
About to start TCP server...
|
|
||||||
-- log_test0 begin ---------------------------------------------------
|
-- log_test0 begin ---------------------------------------------------
|
||||||
CRITICAL:ERR:Message 0
|
CRITICAL:ERR:Message 0
|
||||||
ERROR:ERR:Message 1
|
ERROR:ERR:Message 1
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
|
Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from select import select
|
import select
|
||||||
import os, sys, string, struct, types, cPickle, cStringIO
|
import os, sys, string, struct, types, cPickle, cStringIO
|
||||||
import socket, threading, time, locale
|
import socket, threading, time, locale
|
||||||
import logging, logging.handlers, logging.config
|
import logging, logging.handlers, logging.config
|
||||||
|
@ -64,7 +64,6 @@ def handle(self):
|
||||||
if len(chunk) < 4:
|
if len(chunk) < 4:
|
||||||
break
|
break
|
||||||
slen = struct.unpack(">L", chunk)[0]
|
slen = struct.unpack(">L", chunk)[0]
|
||||||
#print slen
|
|
||||||
chunk = self.connection.recv(slen)
|
chunk = self.connection.recv(slen)
|
||||||
while len(chunk) < slen:
|
while len(chunk) < slen:
|
||||||
chunk = chunk + self.connection.recv(slen - len(chunk))
|
chunk = chunk + self.connection.recv(slen - len(chunk))
|
||||||
|
@ -102,13 +101,19 @@ def __init__(self, host='localhost',
|
||||||
def serve_until_stopped(self):
|
def serve_until_stopped(self):
|
||||||
abort = 0
|
abort = 0
|
||||||
while not abort:
|
while not abort:
|
||||||
rd, wr, ex = select([self.socket.fileno()],
|
rd, wr, ex = select.select([self.socket.fileno()],
|
||||||
[], [],
|
[], [],
|
||||||
self.timeout)
|
self.timeout)
|
||||||
if rd:
|
if rd:
|
||||||
self.handle_request()
|
self.handle_request()
|
||||||
abort = self.abort
|
abort = self.abort
|
||||||
|
|
||||||
|
def process_request(self, request, client_address):
|
||||||
|
#import threading
|
||||||
|
t = threading.Thread(target = self.finish_request,
|
||||||
|
args = (request, client_address))
|
||||||
|
t.start()
|
||||||
|
|
||||||
def runTCP(tcpserver):
|
def runTCP(tcpserver):
|
||||||
tcpserver.serve_until_stopped()
|
tcpserver.serve_until_stopped()
|
||||||
|
|
||||||
|
@ -421,7 +426,7 @@ def test_main():
|
||||||
#Set up servers
|
#Set up servers
|
||||||
threads = []
|
threads = []
|
||||||
tcpserver = LogRecordSocketReceiver()
|
tcpserver = LogRecordSocketReceiver()
|
||||||
sys.stdout.write("About to start TCP server...\n")
|
#sys.stdout.write("About to start TCP server...\n")
|
||||||
threads.append(threading.Thread(target=runTCP, args=(tcpserver,)))
|
threads.append(threading.Thread(target=runTCP, args=(tcpserver,)))
|
||||||
|
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
|
@ -447,18 +452,17 @@ def test_main():
|
||||||
test3()
|
test3()
|
||||||
banner("log_test3", "end")
|
banner("log_test3", "end")
|
||||||
|
|
||||||
banner("logrecv output", "begin")
|
|
||||||
sys.stdout.write(sockOut.getvalue())
|
|
||||||
sockOut.close()
|
|
||||||
banner("logrecv output", "end")
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
#shut down server
|
#shut down server
|
||||||
tcpserver.abort = 1
|
tcpserver.abort = 1
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
banner("logrecv output", "begin")
|
||||||
|
sys.stdout.write(sockOut.getvalue())
|
||||||
|
sockOut.close()
|
||||||
|
banner("logrecv output", "end")
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.stdout.write("test_logging\n")
|
sys.stdout.write("test_logging\n")
|
||||||
test_main()
|
test_main()
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
Loading…
Reference in New Issue