@@ -91,22 +91,26 @@ def main():
91
91
tablet_ids = create_tablet (args .owner_idx , args .channels , args .count )
92
92
print ('TabletIds# %s' % ', ' .join (map (str , tablet_ids )))
93
93
94
- if args .action == 'initialize' :
95
- cmd = text_format .Parse (args .proto_file .read (), TTestShardControlRequest .TCmdInitialize ())
96
- if args .tsserver is not None :
97
- host , sep , port = args .tsserver .partition (':' )
98
- port = int (port ) if sep else default_tsserver_port
99
- sockaddr = None
100
- for _ , _ , _ , _ , sockaddr in socket .getaddrinfo (host , port , socket .AF_INET6 ):
101
- break
102
- if sockaddr is None :
103
- print ('Failed to resolve hostname %s' % host , file = sys .stderr )
104
- sys .exit (1 )
105
- cmd .StorageServerHost = sockaddr [0 ]
106
- with multiprocessing .Pool (None ) as p :
107
- status = 0
108
- for r in p .imap_unordered (init_tablet , ((tablet_id , cmd ) for tablet_id in tablet_ids ), 1 ):
109
- if r is not None :
110
- sys .stderr .write (r )
111
- status = 1
112
- sys .exit (status )
94
+ try :
95
+ if args .action == 'initialize' :
96
+ cmd = text_format .Parse (args .proto_file .read (), TTestShardControlRequest .TCmdInitialize ())
97
+ if args .tsserver is not None :
98
+ host , sep , port = args .tsserver .partition (':' )
99
+ port = int (port ) if sep else default_tsserver_port
100
+ sockaddr = None
101
+ for _ , _ , _ , _ , sockaddr in socket .getaddrinfo (host , port , socket .AF_INET6 ):
102
+ break
103
+ if sockaddr is None :
104
+ print ('Failed to resolve hostname %s' % host , file = sys .stderr )
105
+ sys .exit (1 )
106
+ cmd .StorageServerHost = sockaddr [0 ]
107
+ with multiprocessing .Pool (None ) as p :
108
+ status = 0
109
+ for r in p .imap_unordered (init_tablet , ((tablet_id , cmd ) for tablet_id in tablet_ids ), 1 ):
110
+ if r is not None :
111
+ sys .stderr .write (r )
112
+ status = 1
113
+ sys .exit (status )
114
+ finally :
115
+ if args .proto_file :
116
+ args .proto_file .close ()
0 commit comments