[py-svn] r45844 - py/branch/session-cleanups/py/execnet
fijal at codespeak.net
fijal at codespeak.net
Sat Aug 18 12:41:09 CEST 2007
Author: fijal
Date: Sat Aug 18 12:41:09 2007
New Revision: 45844
Modified:
py/branch/session-cleanups/py/execnet/inputoutput.py
Log:
Hum. I don't like the idea, but this lock prevents segfault and/or
double free.
Modified: py/branch/session-cleanups/py/execnet/inputoutput.py
==============================================================================
--- py/branch/session-cleanups/py/execnet/inputoutput.py (original)
+++ py/branch/session-cleanups/py/execnet/inputoutput.py Sat Aug 18 12:41:09 2007
@@ -3,7 +3,7 @@
across process or computer barriers.
"""
-import socket, os, sys
+import socket, os, sys, thread
class SocketIO:
server_stmt = """
@@ -76,6 +76,7 @@
msvcrt.setmode(outfile.fileno(), os.O_BINARY)
self.outfile, self.infile = infile, outfile
self.readable = self.writeable = True
+ self.lock = thread.allocate_lock()
def read(self, numbytes):
"""Read exactly 'bytes' bytes from the pipe. """
@@ -99,6 +100,10 @@
self.infile.close()
self.readable = None
def close_write(self):
- if self.writeable:
- self.outfile.close()
- self.writeable = None
+ self.lock.acquire()
+ try:
+ if self.writeable:
+ self.outfile.close()
+ self.writeable = None
+ finally:
+ self.lock.release()
More information about the pytest-commit
mailing list