@@ -74,23 +74,37 @@ class _Client(object):
74
74
"""
75
75
76
76
def __init__ (self , * args , ** kwargs ):
77
- # type: (*Optional[str], **Any) -> None
77
+ # type: (*Any, **Any) -> None
78
+ self .options = get_options (* args , ** kwargs ) # type: Dict[str, Any]
79
+ self ._init_impl ()
80
+
81
+ def __getstate__ (self ):
82
+ # type: () -> Any
83
+ return {"options" : self .options }
84
+
85
+ def __setstate__ (self , state ):
86
+ # type: (Any) -> None
87
+ self .options = state ["options" ]
88
+ self ._init_impl ()
89
+
90
+ def _init_impl (self ):
91
+ # type: () -> None
78
92
old_debug = _client_init_debug .get (False )
79
93
try :
80
- self .options = options = get_options (* args , ** kwargs ) # type: ignore
81
- _client_init_debug .set (options ["debug" ])
82
- self .transport = make_transport (options )
94
+ _client_init_debug .set (self .options ["debug" ])
95
+ self .transport = make_transport (self .options )
83
96
84
97
request_bodies = ("always" , "never" , "small" , "medium" )
85
- if options ["request_bodies" ] not in request_bodies :
98
+ if self . options ["request_bodies" ] not in request_bodies :
86
99
raise ValueError (
87
100
"Invalid value for request_bodies. Must be one of {}" .format (
88
101
request_bodies
89
102
)
90
103
)
91
104
92
105
self .integrations = setup_integrations (
93
- options ["integrations" ], with_defaults = options ["default_integrations" ]
106
+ self .options ["integrations" ],
107
+ with_defaults = self .options ["default_integrations" ],
94
108
)
95
109
finally :
96
110
_client_init_debug .set (old_debug )
0 commit comments