Skip to content

SG-43417 Isolate publisher log handler per dialog instance#218

Draft
chenm1adsk wants to merge 1 commit into
masterfrom
ticket/SG-43417-multi-instance-robustness
Draft

SG-43417 Isolate publisher log handler per dialog instance#218
chenm1adsk wants to merge 1 commit into
masterfrom
ticket/SG-43417-multi-instance-robustness

Conversation

@chenm1adsk
Copy link
Copy Markdown
Contributor

@chenm1adsk chenm1adsk commented May 29, 2026

Summary

Fix log handler cross-talk between simultaneously open publisher dialogs.

When two publisher dialogs are open in the same Python process, log records emitted by hooks in Dialog A also show up in Dialog B's progress widget. Each dialog's progress tree gets polluted with the other dialog's log lines.

Root cause

PublishLogWrapper.__init__ calls logging.getLogger("<bundle>.hook") with the same name for every instance. logging.getLogger(name) is cached by name and returns the same Logger object, so each dialog's addHandler(self._handler) accumulates on the shared logger. A log record then dispatches to every attached handler, including the other dialog's.

Fix

Append a uuid.uuid4().hex suffix to the logger name in PublishLogWrapper.__init__ so each instance gets its own Logger object.

  • Prefix <bundle>.hook. is preserved for any consumers that filter by prefix.
  • propagate = False is already set, so the unique child logger does not bubble up the hierarchy.
  • uuid is stdlib, no new dependency.

Files

  • python/tk_multi_publish2/progress/publish_logging.py

Test plan

  • Open one publisher dialog, run validate/publish, confirm log output behaves exactly as before.
  • Open two publisher dialogs simultaneously, trigger hook logs in Dialog A, confirm Dialog B's progress widget no longer mirrors them.

Issue or Context:
When two publisher dialogs are open simultaneously in the same Python
process, log records emitted by hooks in Dialog A also show up in
Dialog B's progress widget. Each dialog's progress tree gets polluted
with the other dialog's log lines.

Root Cause:
`PublishLogWrapper.__init__` calls `logging.getLogger("<bundle>.hook")`
with the same name for every instance. `logging.getLogger(name)` is
cached by name and returns the same Logger object, so each dialog's
`addHandler(self._handler)` accumulates on the shared logger. A log
record then dispatches to every attached handler, including the other
dialog's.

Fix Applied:
Append a `uuid.uuid4().hex` suffix to the logger name in
`PublishLogWrapper.__init__` so each instance gets its own Logger
object. The prefix `<bundle>.hook.` is preserved for any consumers
that filter by prefix. `propagate = False` is already set, so the
unique child logger does not bubble up the hierarchy.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes log handler cross-talk between simultaneously open publisher dialogs. Previously, PublishLogWrapper.__init__ called logging.getLogger("<bundle>.hook") with the same name for every instance, so each dialog's handler accumulated on the same shared Logger, and records emitted in one dialog were dispatched to handlers attached by the other. The fix appends a uuid.uuid4().hex suffix to the logger name so each instance gets a unique Logger.

Changes:

  • Import uuid in publish_logging.py.
  • Append a per-instance uuid.uuid4().hex suffix to the hook logger name to isolate handlers per dialog instance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +102 to +103
unique_id = uuid.uuid4().hex
full_log_path = "%s.hook.%s" % (self._bundle.logger.name, unique_id)
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.79%. Comparing base (8be9070) to head (dedba87).

Files with missing lines Patch % Lines
...thon/tk_multi_publish2/progress/publish_logging.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
- Coverage   40.81%   40.79%   -0.02%     
==========================================
  Files          63       63              
  Lines        5109     5111       +2     
==========================================
  Hits         2085     2085              
- Misses       3024     3026       +2     
Flag Coverage Δ
Linux 40.79% <0.00%> (-0.02%) ⬇️
Python-3.10 40.79% <0.00%> (-0.02%) ⬇️
Python-3.11 40.79% <0.00%> (-0.02%) ⬇️
Python-3.13 40.79% <0.00%> (-0.02%) ⬇️
Python-3.9 40.80% <0.00%> (-0.02%) ⬇️
Windows 40.79% <0.00%> (-0.02%) ⬇️
macOS 40.79% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants