@@ -33,6 +33,7 @@ def __init__(self, client: typing.Optional[GreengrassCoreIPCClient] = None,
3333 if executor is True :
3434 executor = concurrent .futures .ThreadPoolExecutor ()
3535 self .executor = executor
36+ self .ignore_executor_exceptions = False
3637
3738 def close (self , * , executor_wait = True ) -> concurrent .futures .Future :
3839 """
@@ -49,6 +50,9 @@ def close(self, *, executor_wait=True) -> concurrent.futures.Future:
4950 of None if the shutdown was clean and user-initiated.
5051 """
5152 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
5256 if self .executor is not None :
5357 self .executor .shutdown (wait = executor_wait )
5458 return fut
@@ -84,7 +88,11 @@ def __create_stream_handler(real_self, operation, on_stream_event, on_stream_err
8488 on_stream_event = real_self .__wrap_error (on_stream_event )
8589 def handler (self , event ):
8690 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
8896 else :
8997 on_stream_event (event )
9098 setattr (stream_handler_type , "on_stream_event" , handler )
@@ -97,7 +105,11 @@ def handler(self, error):
97105 on_stream_closed = real_self .__wrap_error (on_stream_closed )
98106 def handler (self ):
99107 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
101113 else :
102114 on_stream_closed ()
103115 setattr (stream_handler_type , "on_stream_closed" , handler )
@@ -144,6 +156,29 @@ def authorize_client_device_action_async(self, *,
144156 write_future = operation .activate (request )
145157 return self .__combine_futures (write_future , operation .get_response ())
146158
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+
147182 def create_debug_password (self ) -> model .CreateDebugPasswordResponse :
148183 """
149184 Perform the CreateDebugPassword operation synchronously.
@@ -168,7 +203,8 @@ def create_local_deployment(self, *,
168203 component_to_configuration : typing .Optional [typing .Dict [str , typing .Dict [str , typing .Any ]]] = None ,
169204 component_to_run_with_info : typing .Optional [typing .Dict [str , model .RunWithInfo ]] = None ,
170205 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 :
172208 """
173209 Perform the CreateLocalDeployment operation synchronously.
174210
@@ -180,8 +216,9 @@ def create_local_deployment(self, *,
180216 component_to_run_with_info:
181217 recipe_directory_path:
182218 artifacts_directory_path:
219+ failure_handling_policy: FailureHandlingPolicy enum value
183220 """
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 ()
185222
186223 def create_local_deployment_async (self , * ,
187224 group_name : typing .Optional [str ] = None ,
@@ -190,7 +227,8 @@ def create_local_deployment_async(self, *,
190227 component_to_configuration : typing .Optional [typing .Dict [str , typing .Dict [str , typing .Any ]]] = None ,
191228 component_to_run_with_info : typing .Optional [typing .Dict [str , model .RunWithInfo ]] = None ,
192229 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]
194232 """
195233 Perform the CreateLocalDeployment operation asynchronously.
196234
@@ -202,8 +240,9 @@ def create_local_deployment_async(self, *,
202240 component_to_run_with_info:
203241 recipe_directory_path:
204242 artifacts_directory_path:
243+ failure_handling_policy: FailureHandlingPolicy enum value
205244 """
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 )
207246 operation = self .client .new_create_local_deployment ()
208247 write_future = operation .activate (request )
209248 return self .__combine_futures (write_future , operation .get_response ())
0 commit comments