Thread-safe sockets?

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Sat Apr 13 06:31:56 EDT 2002


I'm working with a ThreadedTCPServer and the following question came
up: Is it safe for two different threads to use the
StreamRequestHandler's rfile and wfile simultaneously? (I.e. one
thread reads and another writes -- no simultaneous reading or
writing.) These file-like objects are created with the socket.makefile
method.

Since the two operations seem so unrelated, it would also seem that
this is safe -- but I'm worried that there may be (perhaps
paltform-dependent) thread-unsafe interference between the two at some
lower level. Does anyone know?

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list