Skip to content

Commit ba4327d

Browse files
committed
[IMP] queue_job: show db name in channel config logs
1 parent 6f24e0b commit ba4327d

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

queue_job/jobrunner/channels.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,16 @@ def simple_configure(self, config_string):
10381038
for config in ChannelManager.parse_simple_config(config_string):
10391039
self.get_channel_from_config(config)
10401040

1041-
def configure(self, configs):
1042-
"""Configure the channel manager from list of :class:`ChannelConfig`"""
1041+
def configure(self, configs, db_name=None):
1042+
"""Configure the channel manager from list of :class:`ChannelConfig`
1043+
1044+
:param db_name: used to show the database name in the
1045+
logs when using per-database channels
1046+
"""
10431047
for config in configs:
1044-
self.get_channel_from_config(asdict(config))
1048+
self.get_channel_from_config(asdict(config), db_name=db_name)
10451049

1046-
def get_channel_from_config(self, config):
1050+
def get_channel_from_config(self, config, db_name=None):
10471051
"""Return a Channel object from a parsed configuration.
10481052
10491053
If the channel does not exist it is created.
@@ -1055,7 +1059,10 @@ def get_channel_from_config(self, config):
10551059
"""
10561060
channel = self.get_channel_by_name(config["name"], autocreate=True)
10571061
channel.configure(config)
1058-
_logger.info("Configured channel: %s", channel)
1062+
if db_name:
1063+
_logger.info("Configured channel: %s (db: %s)", channel, db_name)
1064+
else:
1065+
_logger.info("Configured channel: %s", channel)
10591066
return channel
10601067

10611068
def get_channel_by_name(

queue_job/jobrunner/runner.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,16 @@ def _unique_channel_managers(channel_managers):
572572
return result
573573

574574
@staticmethod
575-
def _create_paused_root_channel_manager():
575+
def _create_paused_root_channel_manager(db_name=None):
576576
"""Create a channel manager with a single root and paused channel
577577
578578
It is used when the channels configuration cannot be used because
579579
of a misconfiguration or because a database schema is outdated.
580580
"""
581581
channel_manager = ChannelManager()
582-
channel_manager.configure([ChannelConfig(name="root", capacity=0, paused=True)])
582+
channel_manager.configure(
583+
[ChannelConfig(name="root", capacity=0, paused=True)], db_name=db_name
584+
)
583585
return channel_manager
584586

585587
def _build_channel_manager(self, db):
@@ -598,7 +600,7 @@ def _build_channel_manager(self, db):
598600
_logger.error(
599601
"database %s schema is outdated, -u queue_job required", db.db_name
600602
)
601-
return self._create_paused_root_channel_manager()
603+
return self._create_paused_root_channel_manager(db_name=db.db_name)
602604

603605
root_config = next(
604606
(config for config in channels_config if config.name == "root"), None
@@ -617,7 +619,7 @@ def _build_channel_manager(self, db):
617619

618620
channel_manager = ChannelManager()
619621
try:
620-
channel_manager.configure(channels_config)
622+
channel_manager.configure(channels_config, db_name=db.db_name)
621623
except ValueError:
622624
# A bad channel configuration on a single database
623625
# (e.g. sequential with a capacity != 1) should not
@@ -629,7 +631,7 @@ def _build_channel_manager(self, db):
629631
db.db_name,
630632
exc_info=True,
631633
)
632-
return self._create_paused_root_channel_manager()
634+
return self._create_paused_root_channel_manager(db_name=db.db_name)
633635
return channel_manager
634636

635637
def _reconfigure_db(self, db_name):

0 commit comments

Comments
 (0)