Skip to content

Threaded worker not stopping even after keyboard interrupt. #4510

Answered by OoiYenKai
OoiYenKai asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you guys for your suggestions and advice. I have successfully came up with a way to fix my issue. I am going to post the solution here for anyone who might be facing the same issue as me.

Firstly i read through the doc on workers and followed the example and avoided updating my UI directly from a thread by modifying my code as such:

    def on_mount(self) -> None:
        # Running an infinite loop with interval of 100ms
        self.DecodingStatus = self.set_interval(0.001, self.get_speed, pause=False)

    @work(exclusive=True, thread=True)
    async def get_speed(self) -> None:
        speed = float(decoding_speed())
        await self.call_from_thread(self.update_ui, speed)

    d…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@willmcgugan
Comment options

@OoiYenKai
Comment options

Comment options

You must be logged in to vote
1 reply
@OoiYenKai
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by OoiYenKai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants