MCPcopy
hub / github.com/django/django / update_connections_time_zone

Function update_connections_time_zone

django/test/signals.py:60–84  ·  view source on GitHub ↗
(*, setting, **kwargs)

Source from the content-addressed store, hash-verified

58
59@receiver(setting_changed)
60def update_connections_time_zone(*, setting, **kwargs):
61 if setting == "TIME_ZONE":
62 # Reset process time zone
63 if hasattr(time, "tzset"):
64 if kwargs["value"]:
65 os.environ["TZ"] = kwargs["value"]
66 else:
67 os.environ.pop("TZ", None)
68 time.tzset()
69
70 # Reset local time zone cache
71 timezone.get_default_timezone.cache_clear()
72
73 # Reset the database connections' time zone
74 if setting in {"TIME_ZONE", "USE_TZ"}:
75 for conn in connections.all(initialized_only=True):
76 try:
77 del conn.timezone
78 except AttributeError:
79 pass
80 try:
81 del conn.timezone_name
82 except AttributeError:
83 pass
84 conn.ensure_timezone()
85
86
87@receiver(setting_changed)

Callers

nothing calls this directly

Calls 3

popMethod · 0.45
allMethod · 0.45
ensure_timezoneMethod · 0.45

Tested by

no test coverage detected