mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
request: Weaken ZulipRequestNotes.tornado_handler reference.
This prevents a memory leak arising from Python’s inability to collect a reference cycle from a WeakKeyDictionary value to its key (https://bugs.python.org/issue44680). Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
7c32134fb5
commit
6564b258f1
@@ -3,6 +3,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import weakref
|
||||
from contextlib import contextmanager
|
||||
from functools import wraps
|
||||
from typing import (
|
||||
@@ -310,7 +311,6 @@ class HostRequestMock(HttpRequest):
|
||||
self.POST[key] = str(post_data[key])
|
||||
self.method = "POST"
|
||||
|
||||
self._tornado_handler = DummyHandler()
|
||||
self._log_data: Dict[str, Any] = {}
|
||||
if meta_data is None:
|
||||
self.META = {"PATH_INFO": "test"}
|
||||
@@ -324,7 +324,7 @@ class HostRequestMock(HttpRequest):
|
||||
request_notes_map[self] = ZulipRequestNotes(
|
||||
client_name="",
|
||||
log_data={},
|
||||
tornado_handler=tornado_handler,
|
||||
tornado_handler=None if tornado_handler is None else weakref.ref(tornado_handler),
|
||||
client=get_client(client_name) if client_name is not None else None,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user