-
Notifications
You must be signed in to change notification settings - Fork 288
Open
Description
Hi team,
I'm getting this error intermittently:
Traceback (most recent call last):
File <SNIP>
with freezegun.freeze_time(lambda: datetime(today.year,
File " <SNIP>/python3.11/site-packages/freezegun/api.py", line 633, in __enter__
return self.start()
^^^^^^^^^^^^
File "<SNIP>/python3.11/site-packages/freezegun/api.py", line 714, in start
for mod_name, module in list(sys.modules.items()):
^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: dictionary changed size during iterationUnfortunately, I don't have a reproducer yet. Would something like this work here?
mod_names = list(sys.modules.keys())
for mod_name in mod_names:
module = sys.modules[mod_name]
if mod_name is None or module is None or mod_name == __name__:
continue
elif mod_name.startswith(self.ignore) or mod_name.endswith('.six.moves'):
continue
elif (not hasattr(module, "__name__") or module.__name__ in ('datetime', 'time')):
continue
module_attrs = _get_cached_module_attributes(module)
for attribute_name, attribute_value in module_attrs:
fake = fakes.get(id(attribute_value))
if fake:
setattr(module, attribute_name, fake)
add_change((module, attribute_name, attribute_value))Please let me know if I'm missing something.
jokatzke
Metadata
Metadata
Assignees
Labels
No labels