Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

populate_db: Explicitly close memcached connection.

Anders Kaseorg8682ea1a649c
diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py
index 4abfc3f80a1..52c07867dcf 100644
--- a/zilencer/management/commands/populate_db.py
+++ b/zilencer/management/commands/populate_db.py
@@ -109,10 +109,14 @@ def clear_database() -> None:
# and; we only need to flush memcached if we're populating a
# database that would be used with it (i.e. zproject.dev_settings).
if default_cache["BACKEND"] == "zerver.lib.singleton_bmemcached.SingletonBMemcached":
- bmemcached.Client(
+ memcached_client = bmemcached.Client(
(default_cache["LOCATION"],),
**default_cache["OPTIONS"],
- ).flush_all()
+ )
+ try:
+ memcached_client.flush_all()
+ finally:
+ memcached_client.disconnect_all()
model: Any = None # Hack because mypy doesn't know these are model classes