@@ -193,7 +193,7 @@ def client_response_hook(span: Span, message: dict):
193193import urllib
194194from functools import wraps
195195from timeit import default_timer
196- from typing import Tuple
196+ from typing import Tuple , List , Dict
197197
198198from asgiref .compatibility import guarantee_single_callable
199199
@@ -277,19 +277,23 @@ def append_keys(key):
277277 if isinstance (key , bytes ):
278278 returnable .append (key .decode ("utf8" ))
279279 elif isinstance (key , str ):
280- returnable .append (key )
280+ returnable .append (key )
281281
282- #carrier is a dict, so iterate over .items()
283- for _key , _val in carrier .items ():
284-
285- #if we have another dict, lets make a recursive call
286- if isinstance (_val , Dict ):
282+ def append_dict_keys (key , val ):
287283 #append our current key
288284 append_keys (_key )
289285
290286 #append all keys within the dict
291287 for x in self .keys (_val ):
292- append_keys (x )
288+ append_keys (x )
289+
290+ #carrier is a dict, so iterate over .items()
291+ for _key , _val in carrier .items ():
292+
293+ #if we have another dict, lets make a recursive call
294+ if isinstance (_val , Dict ):
295+
296+ append_dict_keys (_key , _val )
293297
294298 # if we have a list, lets iter over that. List can contain tuples(headers) dicts and string so lets approach them all as well
295299 elif isinstance (_val , List ):
@@ -301,11 +305,9 @@ def append_keys(key):
301305
302306 #check for the dict
303307 elif isinstance (list_key , Dict ):
304- append_keys (_key )
305308
306- #append all keys within the dict
307- for x in self .keys (_val ):
308- append_keys (x )
309+ append_dict_keys (_key , _val )
310+
309311 else :
310312 append_keys (list_key )
311313
0 commit comments