Skip to content

fix: ensure time is logged even when exception is raised in logt()#2194

Open
AHS0003 wants to merge 1 commit intomicrosoft:mainfrom
AHS0003:fix/logt-exception-handling
Open

fix: ensure time is logged even when exception is raised in logt()#2194
AHS0003 wants to merge 1 commit intomicrosoft:mainfrom
AHS0003:fix/logt-exception-handling

Conversation

@AHS0003
Copy link
Copy Markdown

@AHS0003 AHS0003 commented Apr 18, 2026

Motivation and Context

The logt context manager in qlib/log.py places log_cost_time outside the try/finally block. This means if an exception is raised inside a with TimeInspector.logt(): block, the time is never logged and the time mark pushed onto the stack is never popped, causing a stack leak.

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

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.

1 participant