Skip to content

Add prompt resource cleanup functionality#3038

Merged
harendra-kumar merged 6 commits intomasterfrom
prompt-cleanup1
Jun 24, 2025
Merged

Add prompt resource cleanup functionality#3038
harendra-kumar merged 6 commits intomasterfrom
prompt-cleanup1

Conversation

@harendra-kumar
Copy link
Copy Markdown
Member

@harendra-kumar harendra-kumar commented May 22, 2025

See also: #3039 for a small enhancement.

-- actions that are automatically invoked on exception or after the effect
-- function is done.
{-# INLINE cleanupEffectIO #-}
cleanupEffectIO :: (MonadIO m, MonadCatch m) =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why store the cleanup in an IORef and invoke it later? Why not just run the action directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The ref is passed to the action which stores the cleanup. We use the ref to cleanup anything registered by the action. Therefore, ref is a way to communicate between the action and the exception handler.

@harendra-kumar harendra-kumar merged commit 5adac65 into master Jun 24, 2025
18 of 21 checks passed
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