66#![ deny( clippy:: all) ]
77
88use aws_config:: Region ;
9+ use std:: sync:: LazyLock ;
10+
11+ static DAFNY_TOKIO_RUNTIME : LazyLock < tokio:: runtime:: Runtime > = LazyLock :: new ( || {
12+ tokio:: runtime:: Builder :: new_multi_thread ( )
13+ . enable_all ( )
14+ . build ( )
15+ . unwrap ( )
16+ } ) ;
917
1018impl crate :: r#software:: amazon:: cryptography:: services:: kms:: internaldafny:: _default {
1119 #[ allow( non_snake_case) ]
@@ -14,11 +22,17 @@ impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_def
1422 dafny_runtime:: dafny_runtime_conversions:: unicode_chars_false:: dafny_string_to_string (
1523 region,
1624 ) ;
17- let shared_config = tokio:: task:: block_in_place ( || {
18- tokio:: runtime:: Handle :: current ( ) . block_on ( async {
19- aws_config:: load_defaults ( aws_config:: BehaviorVersion :: v2024_03_28 ( ) ) . await
20- } )
21- } ) ;
25+
26+ let shared_config = match tokio:: runtime:: Handle :: try_current ( ) {
27+ Ok ( curr) => tokio:: task:: block_in_place ( || {
28+ curr. block_on ( async {
29+ aws_config:: load_defaults ( aws_config:: BehaviorVersion :: v2024_03_28 ( ) ) . await
30+ } )
31+ } ) ,
32+ Err ( _) => DAFNY_TOKIO_RUNTIME . block_on ( aws_config:: load_defaults (
33+ aws_config:: BehaviorVersion :: v2024_03_28 ( ) ,
34+ ) ) ,
35+ } ;
2236
2337 let shared_config = shared_config
2438 . to_builder ( )
@@ -34,11 +48,17 @@ impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_def
3448
3549 #[ allow( non_snake_case) ]
3650 pub fn KMSClient ( ) -> :: std:: rc:: Rc < crate :: r#_Wrappers_Compile:: Result < :: dafny_runtime:: Object < dyn crate :: software:: amazon:: cryptography:: services:: kms:: internaldafny:: types:: IKMSClient > , :: std:: rc:: Rc < crate :: software:: amazon:: cryptography:: services:: kms:: internaldafny:: types:: Error > > > {
37- let shared_config = tokio:: task:: block_in_place ( || {
38- tokio:: runtime:: Handle :: current ( ) . block_on ( async {
39- aws_config:: load_defaults ( aws_config:: BehaviorVersion :: v2024_03_28 ( ) ) . await
40- } )
41- } ) ;
51+ let shared_config = match tokio:: runtime:: Handle :: try_current ( ) {
52+ Ok ( curr) => tokio:: task:: block_in_place ( || {
53+ curr. block_on ( async {
54+ aws_config:: load_defaults ( aws_config:: BehaviorVersion :: v2024_03_28 ( ) ) . await
55+ } )
56+ } ) ,
57+ Err ( _) => DAFNY_TOKIO_RUNTIME . block_on ( aws_config:: load_defaults (
58+ aws_config:: BehaviorVersion :: v2024_03_28 ( ) ,
59+ ) ) ,
60+ } ;
61+
4262 let inner = aws_sdk_kms:: Client :: new ( & shared_config) ;
4363 let client = crate :: deps:: com_amazonaws_kms:: client:: Client { inner } ;
4464 let dafny_client = :: dafny_runtime:: upcast_object ( ) ( :: dafny_runtime:: object:: new ( client) ) ;
0 commit comments