| Conditions | 4 | 
| Total Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 1 | #!/usr/bin/env python2.7  | 
            ||
| 8 | def wait_net_service(server, port, sleep=10, timeout=5):  | 
            ||
| 9 | """ Wait for network service to appear  | 
            ||
| 10 | @param timeout: in seconds, if None or 0 wait forever  | 
            ||
| 11 | @return: True of False, if timeout is None may return only True or  | 
            ||
| 12 | throw unhandled network exception  | 
            ||
| 13 | """  | 
            ||
| 14 | |||
| 15 | s = socket.socket()  | 
            ||
| 16 | |||
| 17 | while True:  | 
            ||
| 18 | try:  | 
            ||
| 19 | s.settimeout(timeout)  | 
            ||
| 20 | s.connect((server, port))  | 
            ||
| 21 | except:  | 
            ||
| 22 | time.sleep(sleep)  | 
            ||
| 23 | else:  | 
            ||
| 24 | s.close()  | 
            ||
| 25 | return True  | 
            ||
| 26 | |||
| 42 |