@@ -535,17 +535,10 @@ async def _execute_command(
535
535
if session :
536
536
# Start a new retryable write unless one was already
537
537
# started for this command.
538
- if (
539
- retryable
540
- and self .is_retryable
541
- and not self .started_retryable_write
542
- and not session .in_transaction
543
- ):
538
+ if retryable and not self .started_retryable_write :
544
539
session ._start_retryable_write ()
545
540
self .started_retryable_write = True
546
- session ._apply_to (
547
- cmd , retryable and self .is_retryable , ReadPreference .PRIMARY , conn
548
- )
541
+ session ._apply_to (cmd , retryable , ReadPreference .PRIMARY , conn )
549
542
conn .send_cluster_time (cmd , session , self .client )
550
543
conn .add_server_api (cmd )
551
544
# CSOT: apply timeout before encoding the command.
@@ -572,11 +565,7 @@ async def _execute_command(
572
565
573
566
# Synthesize the full bulk result without modifying the
574
567
# current one because this write operation may be retried.
575
- if (
576
- retryable
577
- and self .is_retryable
578
- and (retryable_top_level_error or retryable_network_error )
579
- ):
568
+ if retryable and (retryable_top_level_error or retryable_network_error ):
580
569
full = copy .deepcopy (full_result )
581
570
_merge_command (self .ops , self .idx_offset , full , result )
582
571
_throw_client_bulk_write_exception (full , self .verbose_results )
@@ -595,7 +584,7 @@ async def _execute_command(
595
584
_merge_command (self .ops , self .idx_offset , full_result , result )
596
585
break
597
586
598
- if retryable and self . is_retryable :
587
+ if retryable :
599
588
# Retryable writeConcernErrors halt the execution of this batch.
600
589
wce = result .get ("writeConcernError" , {})
601
590
if wce .get ("code" , 0 ) in _RETRYABLE_ERROR_CODES :
0 commit comments