@@ -33,6 +33,7 @@ def __init__(self, client: typing.Optional[GreengrassCoreIPCClient] = None,
33
33
if executor is True :
34
34
executor = concurrent .futures .ThreadPoolExecutor ()
35
35
self .executor = executor
36
+ self .ignore_executor_exceptions = False
36
37
37
38
def close (self , * , executor_wait = True ) -> concurrent .futures .Future :
38
39
"""
@@ -49,6 +50,9 @@ def close(self, *, executor_wait=True) -> concurrent.futures.Future:
49
50
of None if the shutdown was clean and user-initiated.
50
51
"""
51
52
fut = self .client .close ()
53
+
54
+ # events that arrive during the shutdown process will generate executor exceptions, ignore them
55
+ self .ignore_executor_exceptions = True
52
56
if self .executor is not None :
53
57
self .executor .shutdown (wait = executor_wait )
54
58
return fut
@@ -84,7 +88,11 @@ def __create_stream_handler(real_self, operation, on_stream_event, on_stream_err
84
88
on_stream_event = real_self .__wrap_error (on_stream_event )
85
89
def handler (self , event ):
86
90
if real_self .executor is not None :
87
- real_self .executor .submit (on_stream_event , event )
91
+ try :
92
+ real_self .executor .submit (on_stream_event , event )
93
+ except RuntimeError :
94
+ if not real_self .ignore_executor_exceptions :
95
+ raise
88
96
else :
89
97
on_stream_event (event )
90
98
setattr (stream_handler_type , "on_stream_event" , handler )
@@ -97,7 +105,11 @@ def handler(self, error):
97
105
on_stream_closed = real_self .__wrap_error (on_stream_closed )
98
106
def handler (self ):
99
107
if real_self .executor is not None :
100
- real_self .executor .submit (on_stream_closed )
108
+ try :
109
+ real_self .executor .submit (on_stream_closed )
110
+ except RuntimeError :
111
+ if real_self .ignore_executor_exceptions :
112
+ raise
101
113
else :
102
114
on_stream_closed ()
103
115
setattr (stream_handler_type , "on_stream_closed" , handler )
@@ -144,6 +156,29 @@ def authorize_client_device_action_async(self, *,
144
156
write_future = operation .activate (request )
145
157
return self .__combine_futures (write_future , operation .get_response ())
146
158
159
+ def cancel_local_deployment (self , * ,
160
+ deployment_id : typing .Optional [str ] = None ) -> model .CancelLocalDeploymentResponse :
161
+ """
162
+ Perform the CancelLocalDeployment operation synchronously.
163
+
164
+ Args:
165
+ deployment_id:
166
+ """
167
+ return self .cancel_local_deployment_async (deployment_id = deployment_id ).result ()
168
+
169
+ def cancel_local_deployment_async (self , * ,
170
+ deployment_id : typing .Optional [str ] = None ): # type: (...) -> concurrent.futures.Future[model.CancelLocalDeploymentResponse]
171
+ """
172
+ Perform the CancelLocalDeployment operation asynchronously.
173
+
174
+ Args:
175
+ deployment_id:
176
+ """
177
+ request = model .CancelLocalDeploymentRequest (deployment_id = deployment_id )
178
+ operation = self .client .new_cancel_local_deployment ()
179
+ write_future = operation .activate (request )
180
+ return self .__combine_futures (write_future , operation .get_response ())
181
+
147
182
def create_debug_password (self ) -> model .CreateDebugPasswordResponse :
148
183
"""
149
184
Perform the CreateDebugPassword operation synchronously.
@@ -168,7 +203,8 @@ def create_local_deployment(self, *,
168
203
component_to_configuration : typing .Optional [typing .Dict [str , typing .Dict [str , typing .Any ]]] = None ,
169
204
component_to_run_with_info : typing .Optional [typing .Dict [str , model .RunWithInfo ]] = None ,
170
205
recipe_directory_path : typing .Optional [str ] = None ,
171
- artifacts_directory_path : typing .Optional [str ] = None ) -> model .CreateLocalDeploymentResponse :
206
+ artifacts_directory_path : typing .Optional [str ] = None ,
207
+ failure_handling_policy : typing .Optional [str ] = None ) -> model .CreateLocalDeploymentResponse :
172
208
"""
173
209
Perform the CreateLocalDeployment operation synchronously.
174
210
@@ -180,8 +216,9 @@ def create_local_deployment(self, *,
180
216
component_to_run_with_info:
181
217
recipe_directory_path:
182
218
artifacts_directory_path:
219
+ failure_handling_policy: FailureHandlingPolicy enum value
183
220
"""
184
- return self .create_local_deployment_async (group_name = group_name , root_component_versions_to_add = root_component_versions_to_add , root_components_to_remove = root_components_to_remove , component_to_configuration = component_to_configuration , component_to_run_with_info = component_to_run_with_info , recipe_directory_path = recipe_directory_path , artifacts_directory_path = artifacts_directory_path ).result ()
221
+ return self .create_local_deployment_async (group_name = group_name , root_component_versions_to_add = root_component_versions_to_add , root_components_to_remove = root_components_to_remove , component_to_configuration = component_to_configuration , component_to_run_with_info = component_to_run_with_info , recipe_directory_path = recipe_directory_path , artifacts_directory_path = artifacts_directory_path , failure_handling_policy = failure_handling_policy ).result ()
185
222
186
223
def create_local_deployment_async (self , * ,
187
224
group_name : typing .Optional [str ] = None ,
@@ -190,7 +227,8 @@ def create_local_deployment_async(self, *,
190
227
component_to_configuration : typing .Optional [typing .Dict [str , typing .Dict [str , typing .Any ]]] = None ,
191
228
component_to_run_with_info : typing .Optional [typing .Dict [str , model .RunWithInfo ]] = None ,
192
229
recipe_directory_path : typing .Optional [str ] = None ,
193
- artifacts_directory_path : typing .Optional [str ] = None ): # type: (...) -> concurrent.futures.Future[model.CreateLocalDeploymentResponse]
230
+ artifacts_directory_path : typing .Optional [str ] = None ,
231
+ failure_handling_policy : typing .Optional [str ] = None ): # type: (...) -> concurrent.futures.Future[model.CreateLocalDeploymentResponse]
194
232
"""
195
233
Perform the CreateLocalDeployment operation asynchronously.
196
234
@@ -202,8 +240,9 @@ def create_local_deployment_async(self, *,
202
240
component_to_run_with_info:
203
241
recipe_directory_path:
204
242
artifacts_directory_path:
243
+ failure_handling_policy: FailureHandlingPolicy enum value
205
244
"""
206
- request = model .CreateLocalDeploymentRequest (group_name = group_name , root_component_versions_to_add = root_component_versions_to_add , root_components_to_remove = root_components_to_remove , component_to_configuration = component_to_configuration , component_to_run_with_info = component_to_run_with_info , recipe_directory_path = recipe_directory_path , artifacts_directory_path = artifacts_directory_path )
245
+ request = model .CreateLocalDeploymentRequest (group_name = group_name , root_component_versions_to_add = root_component_versions_to_add , root_components_to_remove = root_components_to_remove , component_to_configuration = component_to_configuration , component_to_run_with_info = component_to_run_with_info , recipe_directory_path = recipe_directory_path , artifacts_directory_path = artifacts_directory_path , failure_handling_policy = failure_handling_policy )
207
246
operation = self .client .new_create_local_deployment ()
208
247
write_future = operation .activate (request )
209
248
return self .__combine_futures (write_future , operation .get_response ())
0 commit comments