RuntimeError: dictionary changed size during iteration
nirradi opened this issue · 0 comments
nirradi commented
Code:
app = FastAPI(
title='Service',
version=__version__,
)
@app.on_event("startup")
def startup_event():
print('Will configure logging now')
json_logging.init_fastapi(enable_json=True)
logger = logging.getLogger()
syslog = logging.StreamHandler(sys.stdout)
logger.addHandler(syslog)
Every log now has this error:
return fmt.format(record)
File "/usr/local/lib/python3.10/site-packages/json_logging/formatters.py", line 60, in format
log_object = self._format_log_object(record, request_util=json_logging._request_util)
File "/usr/local/lib/python3.10/site-packages/json_logging/formatters.py", line 151, in _format_log_object
"correlation_id": request_util.get_correlation_id(within_formatter=True),
File "/usr/local/lib/python3.10/site-packages/json_logging/util.py", line 137, in get_correlation_id
request = self.get_request_from_call_stack()
File "/usr/local/lib/python3.10/site-packages/json_logging/util.py", line 190, in get_request_from_call_stack
for key in f_locals:
RuntimeError: dictionary changed size during iteration
Call stack:
....