@@ -246,23 +246,21 @@ def handle_4xx_errors(self, metadata, operation, reason, response, retries, stat
246246 network_delete_concurrency_error_text = 'concurrent'
247247 action_batch_concurrency_error_text = 'executing batches'
248248
249- if message_is_dict and 'errors' in message .keys ():
250- errors = message ['errors' ]
251- if self ._logger :
252- self ._logger .warning (f'{ tag } , { operation } - { status } { reason } { errors } ' )
253- network_deletion_errors = [error for error in message ['errors' ] if network_delete_concurrency_error_text in
254- error ]
255- action_batch_errors = [error for error in message ['errors' ] if action_batch_concurrency_error_text in error ]
256-
257- if network_deletion_errors :
249+ if operation == 'deleteNetwork' and response .status_code == 400 :
250+ if network_delete_concurrency_error_text in message ['errors' ][0 ]:
258251 wait = random .randint (30 , self ._network_delete_retry_wait_time )
259252 if self ._logger :
260253 self ._logger .warning (f'{ tag } , { operation } - { status } { reason } , retrying in { wait } seconds' )
261254 time .sleep (wait )
262255 retries -= 1
263256 if retries == 0 :
264257 raise APIError (metadata , response )
265- elif action_batch_errors :
258+
259+ elif message_is_dict and 'errors' in message .keys ():
260+
261+ action_batch_errors = [error for error in message ['errors' ] if action_batch_concurrency_error_text in error ]
262+
263+ if action_batch_errors :
266264 wait = self ._action_batch_retry_wait_time
267265 if self ._logger :
268266 self ._logger .warning (f'{ tag } , { operation } - { status } { reason } , retrying in { wait } seconds' )
@@ -271,7 +269,7 @@ def handle_4xx_errors(self, metadata, operation, reason, response, retries, stat
271269 if retries == 0 :
272270 raise APIError (metadata , response )
273271
274- if self ._retry_4xx_error :
272+ elif self ._retry_4xx_error :
275273 wait = random .randint (1 , self ._retry_4xx_error_wait_time )
276274 if self ._logger :
277275 self ._logger .warning (f'{ tag } , { operation } - { status } { reason } , retrying in { wait } seconds' )
0 commit comments