File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929from synapse .storage .engines import create_engine
3030from synapse .util .async import sleep
3131from synapse .util .httpresourcetree import create_resource_tree
32- from synapse .util .logcontext import LoggingContext
32+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
3333from synapse .util .manhole import manhole
3434from synapse .util .rlimit import change_resource_limit
3535from synapse .util .versionstring import get_version_string
@@ -187,7 +187,11 @@ def start(config_options):
187187 ps .start_listening (config .worker_listeners )
188188
189189 def run ():
190- with LoggingContext ("run" ):
190+ # make sure that we run the reactor with the sentinel log context,
191+ # otherwise other PreserveLoggingContext instances will get confused
192+ # and complain when they see the logcontext arbitrarily swapping
193+ # between the sentinel and `run` logcontexts.
194+ with PreserveLoggingContext ():
191195 logger .info ("Running" )
192196 change_resource_limit (config .soft_file_limit )
193197 if config .gc_thresholds :
Original file line number Diff line number Diff line change 3535from synapse .storage .engines import create_engine
3636from synapse .util .async import sleep
3737from synapse .util .httpresourcetree import create_resource_tree
38- from synapse .util .logcontext import LoggingContext
38+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
3939from synapse .util .manhole import manhole
4040from synapse .util .rlimit import change_resource_limit
4141from synapse .util .versionstring import get_version_string
@@ -193,7 +193,11 @@ def start(config_options):
193193 ss .start_listening (config .worker_listeners )
194194
195195 def run ():
196- with LoggingContext ("run" ):
196+ # make sure that we run the reactor with the sentinel log context,
197+ # otherwise other PreserveLoggingContext instances will get confused
198+ # and complain when they see the logcontext arbitrarily swapping
199+ # between the sentinel and `run` logcontexts.
200+ with PreserveLoggingContext ():
197201 logger .info ("Running" )
198202 change_resource_limit (config .soft_file_limit )
199203 if config .gc_thresholds :
Original file line number Diff line number Diff line change 3131from synapse .storage .engines import create_engine
3232from synapse .util .async import sleep
3333from synapse .util .httpresourcetree import create_resource_tree
34- from synapse .util .logcontext import LoggingContext
34+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
3535from synapse .util .manhole import manhole
3636from synapse .util .rlimit import change_resource_limit
3737from synapse .util .versionstring import get_version_string
@@ -184,7 +184,11 @@ def start(config_options):
184184 ss .start_listening (config .worker_listeners )
185185
186186 def run ():
187- with LoggingContext ("run" ):
187+ # make sure that we run the reactor with the sentinel log context,
188+ # otherwise other PreserveLoggingContext instances will get confused
189+ # and complain when they see the logcontext arbitrarily swapping
190+ # between the sentinel and `run` logcontexts.
191+ with PreserveLoggingContext ():
188192 logger .info ("Running" )
189193 change_resource_limit (config .soft_file_limit )
190194 if config .gc_thresholds :
Original file line number Diff line number Diff line change 3535from synapse .storage .presence import UserPresenceState
3636from synapse .util .async import sleep
3737from synapse .util .httpresourcetree import create_resource_tree
38- from synapse .util .logcontext import LoggingContext
38+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
3939from synapse .util .manhole import manhole
4040from synapse .util .rlimit import change_resource_limit
4141from synapse .util .versionstring import get_version_string
@@ -193,7 +193,11 @@ def start(config_options):
193193 ps .start_listening (config .worker_listeners )
194194
195195 def run ():
196- with LoggingContext ("run" ):
196+ # make sure that we run the reactor with the sentinel log context,
197+ # otherwise other PreserveLoggingContext instances will get confused
198+ # and complain when they see the logcontext arbitrarily swapping
199+ # between the sentinel and `run` logcontexts.
200+ with PreserveLoggingContext ():
197201 logger .info ("Running" )
198202 change_resource_limit (config .soft_file_limit )
199203 if config .gc_thresholds :
Original file line number Diff line number Diff line change 5252)
5353from synapse .config .homeserver import HomeServerConfig
5454from synapse .crypto import context_factory
55- from synapse .util .logcontext import LoggingContext
55+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
5656from synapse .metrics import register_memory_metrics , get_metrics_for
5757from synapse .metrics .resource import MetricsResource , METRICS_PREFIX
5858from synapse .replication .resource import ReplicationResource , REPLICATION_PREFIX
@@ -456,7 +456,12 @@ def phone_stats_home():
456456 def in_thread ():
457457 # Uncomment to enable tracing of log context changes.
458458 # sys.settrace(logcontext_tracer)
459- with LoggingContext ("run" ):
459+
460+ # make sure that we run the reactor with the sentinel log context,
461+ # otherwise other PreserveLoggingContext instances will get confused
462+ # and complain when they see the logcontext arbitrarily swapping
463+ # between the sentinel and `run` logcontexts.
464+ with PreserveLoggingContext ():
460465 change_resource_limit (hs .config .soft_file_limit )
461466 if hs .config .gc_thresholds :
462467 gc .set_threshold (* hs .config .gc_thresholds )
Original file line number Diff line number Diff line change 3232from synapse .storage .media_repository import MediaRepositoryStore
3333from synapse .util .async import sleep
3434from synapse .util .httpresourcetree import create_resource_tree
35- from synapse .util .logcontext import LoggingContext
35+ from synapse .util .logcontext import LoggingContext , PreserveLoggingContext
3636from synapse .util .manhole import manhole
3737from synapse .util .rlimit import change_resource_limit
3838from synapse .util .versionstring import get_version_string
@@ -190,7 +190,11 @@ def start(config_options):
190190 ss .start_listening (config .worker_listeners )
191191
192192 def run ():
193- with LoggingContext ("run" ):
193+ # make sure that we run the reactor with the sentinel log context,
194+ # otherwise other PreserveLoggingContext instances will get confused
195+ # and complain when they see the logcontext arbitrarily swapping
196+ # between the sentinel and `run` logcontexts.
197+ with PreserveLoggingContext ():
194198 logger .info ("Running" )
195199 change_resource_limit (config .soft_file_limit )
196200 if config .gc_thresholds :
Original file line number Diff line number Diff line change 3131from synapse .storage import DataStore
3232from synapse .util .async import sleep
3333from synapse .util .httpresourcetree import create_resource_tree
34- from synapse .util .logcontext import LoggingContext , preserve_fn
34+ from synapse .util .logcontext import LoggingContext , preserve_fn , \
35+ PreserveLoggingContext
3536from synapse .util .manhole import manhole
3637from synapse .util .rlimit import change_resource_limit
3738from synapse .util .versionstring import get_version_string
@@ -275,7 +276,11 @@ def start(config_options):
275276 ps .start_listening (config .worker_listeners )
276277
277278 def run ():
278- with LoggingContext ("run" ):
279+ # make sure that we run the reactor with the sentinel log context,
280+ # otherwise other PreserveLoggingContext instances will get confused
281+ # and complain when they see the logcontext arbitrarily swapping
282+ # between the sentinel and `run` logcontexts.
283+ with PreserveLoggingContext ():
279284 logger .info ("Running" )
280285 change_resource_limit (config .soft_file_limit )
281286 if config .gc_thresholds :
Original file line number Diff line number Diff line change 4848from synapse .storage .roommember import RoomMemberStore
4949from synapse .util .async import sleep
5050from synapse .util .httpresourcetree import create_resource_tree
51- from synapse .util .logcontext import LoggingContext , preserve_fn
51+ from synapse .util .logcontext import LoggingContext , preserve_fn , \
52+ PreserveLoggingContext
5253from synapse .util .manhole import manhole
5354from synapse .util .rlimit import change_resource_limit
5455from synapse .util .stringutils import random_string
@@ -496,7 +497,11 @@ def start(config_options):
496497 ss .start_listening (config .worker_listeners )
497498
498499 def run ():
499- with LoggingContext ("run" ):
500+ # make sure that we run the reactor with the sentinel log context,
501+ # otherwise other PreserveLoggingContext instances will get confused
502+ # and complain when they see the logcontext arbitrarily swapping
503+ # between the sentinel and `run` logcontexts.
504+ with PreserveLoggingContext ():
500505 logger .info ("Running" )
501506 change_resource_limit (config .soft_file_limit )
502507 if config .gc_thresholds :
You can’t perform that action at this time.
0 commit comments