@@ -102,19 +102,23 @@ def _list(
102
102
sagemaker_boto_client = None ,
103
103
** kwargs
104
104
):
105
+ sagemaker_boto_client = sagemaker_boto_client or _utils .sagemaker_client ()
105
106
next_token = None
106
- while True :
107
- list_request_kwargs = _boto_functions .to_boto (kwargs , cls ._custom_boto_names , cls ._custom_boto_types )
108
- if next_token :
109
- list_request_kwargs [boto_next_token_name ] = next_token
110
- list_method = getattr (sagemaker_boto_client , boto_list_method )
111
- list_method_response = list_method (** list_request_kwargs )
112
- list_items = list_method_response .get (boto_list_items_name , [])
113
- next_token = list_method_response .get (boto_next_token_name )
114
- for item in list_items :
115
- yield list_item_factory (item )
116
- if not next_token :
117
- break
107
+ try :
108
+ while True :
109
+ list_request_kwargs = _boto_functions .to_boto (kwargs , cls ._custom_boto_names , cls ._custom_boto_types )
110
+ if next_token :
111
+ list_request_kwargs [boto_next_token_name ] = next_token
112
+ list_method = getattr (sagemaker_boto_client , boto_list_method )
113
+ list_method_response = list_method (** list_request_kwargs )
114
+ list_items = list_method_response .get (boto_list_items_name , [])
115
+ next_token = list_method_response .get (boto_next_token_name )
116
+ for item in list_items :
117
+ yield list_item_factory (item )
118
+ if not next_token :
119
+ break
120
+ except StopIteration :
121
+ return
118
122
119
123
@classmethod
120
124
def _construct (cls , boto_method_name , sagemaker_boto_client = None , ** kwargs ):
0 commit comments