Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call plugin unload function after stopping event loop #539

Merged

Conversation

Jan200101
Copy link
Contributor

This can prevent race conditions where unload is clearing data but main is still working with it

Please tick as appropriate:

  • I have tested this code on a steam deck or on a PC
  • My changes generate no new errors/warnings
  • This is a bugfix/hotfix
  • This is a new feature

If you're wanting to update a translation or add a new one, please use the weblate page: https://weblate.werwolv.net/projects/decky/

Description

During the unload long-running code is still active causing possible race conditions when unloads cleans up data which main was referencing.

Example Plugin

class Plugin:
    data = []

    async def _main(self):
        while True:
            self.data.append(len(self.data))
            decky_plugin.logger.info(self.data)
            await asyncio.sleep(0.1)

    async def _unload(self):
        self.data = None

@TrainDoctor TrainDoctor reopened this Sep 15, 2023
This can prevent race conditions where unload is clearing data but main is still working with it
@PartyWumpus PartyWumpus added the bug Something isn't working label Nov 11, 2023
@TrainDoctor
Copy link
Member

TrainDoctor commented Dec 16, 2023

Going to give this a go. Apologies it took so long to get to this.
(Edit: Had to manually rebase PR locally for testing purposes.)

Copy link
Member

@TrainDoctor TrainDoctor left a comment

Choose a reason for hiding this comment

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

Tested out on a local version and worked perfectly. Merged!

@TrainDoctor TrainDoctor merged commit 39f4f28 into SteamDeckHomebrew:main Dec 16, 2023
6 checks passed
AAGaming00 pushed a commit that referenced this pull request Dec 29, 2023
This can prevent race conditions where unload is clearing data but main is still working with it
PartyWumpus added a commit that referenced this pull request Feb 9, 2024
PartyWumpus added a commit that referenced this pull request Feb 9, 2024
…#584)

This reverts commit 39f4f28 , because functions (seemingly) don't run after the event loop closes, so the unload function is never actually run.
AAGaming00 pushed a commit that referenced this pull request Feb 14, 2024
…#584)

This reverts commit 39f4f28 , because functions (seemingly) don't run after the event loop closes, so the unload function is never actually run.
bricefriha pushed a commit to bricefriha/decky-loader that referenced this pull request Jun 3, 2024
…rew#539)

This can prevent race conditions where unload is clearing data but main is still working with it
bricefriha pushed a commit to bricefriha/decky-loader that referenced this pull request Jun 3, 2024
…eckHomebrew#539)" (SteamDeckHomebrew#584)

This reverts commit 39f4f28 , because functions (seemingly) don't run after the event loop closes, so the unload function is never actually run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants