mirror of https://github.com/zulip/zulip.git
populate_db: Explicitly close memcached connection.
Fixes warnings like “ResourceWarning: unclosed <socket.socket fd=19, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 46244), raddr=('127.0.0.1', 11211)>” with warnings enabled. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
f3c67103cf
commit
8682ea1a64
|
@ -109,10 +109,14 @@ def clear_database() -> None:
|
||||||
# and; we only need to flush memcached if we're populating a
|
# and; we only need to flush memcached if we're populating a
|
||||||
# database that would be used with it (i.e. zproject.dev_settings).
|
# database that would be used with it (i.e. zproject.dev_settings).
|
||||||
if default_cache["BACKEND"] == "zerver.lib.singleton_bmemcached.SingletonBMemcached":
|
if default_cache["BACKEND"] == "zerver.lib.singleton_bmemcached.SingletonBMemcached":
|
||||||
bmemcached.Client(
|
memcached_client = bmemcached.Client(
|
||||||
(default_cache["LOCATION"],),
|
(default_cache["LOCATION"],),
|
||||||
**default_cache["OPTIONS"],
|
**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
|
model: Any = None # Hack because mypy doesn't know these are model classes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue