@skip('multiple_execute')
@retry_on_failure
def test_makefile_refcount():
 def echoer(port):
  s = socket.socket()
  s.bind(('localhost', port))
  s.listen(5)
  (s2, ignore) = s.accept()
  s2.send(s2.recv(10))
 port = 50008
 thread.start_new_thread(echoer, (port,))
 time.sleep(0)
 s = socket.socket()
 s.connect(('localhost', port))
 f1 = s.makefile('r')
 f2 = s.makefile('w')
 s.close()
 test_msg = 'abc\n'
 f2.write(test_msg)
 f2.flush()
 str = f1.readline()
 Assert((str == test_msg))

@ skip ( 'multiple_execute' ) @ retry_on_failure def test_makefile_refcount ( ) : def echoer ( port ) : s = socket . socket ( ) s . bind ( ( 'localhost' , port ) ) s . listen ( 5 ) ( s2 , ignore ) = s . accept ( ) s2 . send ( s2 . recv ( 10 ) ) port = 50008 thread . start_new_thread ( echoer , ( port , ) ) time . sleep ( 0 ) s = socket . socket ( ) s . connect ( ( 'localhost' , port ) ) f1 = s . makefile ( 'r' ) f2 = s . makefile ( 'w' ) s . close ( ) test_msg = 'abc\n' f2 . write ( test_msg ) f2 . flush ( ) str = f1 . readline ( ) Assert ( ( str == test_msg ) )
ensures that the socket stays open while theres still a file associated .