34
34
35
35
import contextlib
36
36
import os
37
+ import traceback
37
38
import warnings
38
39
import weakref
39
40
from collections import defaultdict
@@ -2580,7 +2581,7 @@ async def run(self) -> T:
2580
2581
# be a persistent outage. Attempting to retry in this case will
2581
2582
# most likely be a waste of time.
2582
2583
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2583
- print (f"Raising timeout error for { self ._operation } " )
2584
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2584
2585
raise
2585
2586
except PyMongoError as exc :
2586
2587
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
@@ -2595,20 +2596,20 @@ async def run(self) -> T:
2595
2596
and exc_code not in helpers_shared ._RETRYABLE_ERROR_CODES
2596
2597
):
2597
2598
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2598
- print (f"Raising error for { self ._operation } " )
2599
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2599
2600
raise
2600
2601
self ._retrying = True
2601
2602
self ._last_error = exc
2602
2603
else :
2603
2604
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2604
- print (f"Raising error for { self ._operation } " )
2605
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2605
2606
raise
2606
2607
2607
2608
# Specialized catch on write operation
2608
2609
if not self ._is_read :
2609
2610
if not self ._retryable :
2610
2611
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2611
- print (f"Raising error for { self ._operation } " )
2612
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2612
2613
raise
2613
2614
if isinstance (exc , ClientBulkWriteException ) and exc .error :
2614
2615
retryable_write_error_exc = isinstance (
@@ -2622,11 +2623,11 @@ async def run(self) -> T:
2622
2623
if not retryable_write_error_exc or self ._is_not_eligible_for_retry ():
2623
2624
if exc .has_error_label ("NoWritesPerformed" ) and self ._last_error :
2624
2625
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2625
- print (f"Raising error for { self ._operation } " )
2626
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2626
2627
raise self ._last_error from exc
2627
2628
else :
2628
2629
if self ._operation in (_Op .LIST_COLLECTIONS , _Op .INSERT ):
2629
- print (f"Raising error for { self ._operation } " )
2630
+ print (f"Raising error for { self ._operation } at { traceback . print_stack ( limit = 1 ) } " )
2630
2631
raise
2631
2632
if self ._bulk :
2632
2633
self ._bulk .retrying = True
0 commit comments