#NEWLINE# def wait_net_service( server , port , sleep = 10 , timeout = 5 ) : #NEWLINE# #INDENT# ' Wait for network service to appear\n        @param timeout: in seconds, if None or 0 wait forever\n        @return: True of False, if timeout is None may return only True or\n                 throw unhandled network exception\n    ' #NEWLINE# s = socket . socket ( ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# s . settimeout ( timeout ) #NEWLINE# s . connect ( ( server , port ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# time . sleep ( sleep ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# s . close ( ) #NEWLINE# return True