Efforts to make ucloud a python package
This commit is contained in:
		
					parent
					
						
							
								bbe09667a6
							
						
					
				
			
			
				commit
				
					
						1e7300b56e
					
				
			
		
					 71 changed files with 241 additions and 1043 deletions
				
			
		
							
								
								
									
										13
									
								
								ucloud/host/helper.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								ucloud/host/helper.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| import socket | ||||
| from contextlib import closing | ||||
| 
 | ||||
| 
 | ||||
| def find_free_port(): | ||||
|     with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: | ||||
|         try: | ||||
|             s.bind(('', 0)) | ||||
|             s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||||
|         except Exception: | ||||
|             return None | ||||
|         else: | ||||
|             return s.getsockname()[1] | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue