Re: Injecting an exception into another thread

CF Bolz-Tereick <[email protected]> Wed, 10 May 2023 08:53:12 +0200
Newsgroups gmane.comp.python.pypy
Message-ID <[email protected]>
Hi Audrey, hi all,

it's almost a year later and the feature has actually been there since a
while and I forgot to write you about it. In case it's still relevant
for you: You can now interrupt other threads like this:

__pypy__.thread._raise_in_thread(thread_id, ExceptionClass)

Cheers,

CF

On 31/05/2022 14:26, Carl Friedrich Bolz-Tereick wrote:
> Hi Audrey,
>
> right, that makes sense. I've opened an issue:
>
> https://foss.heptapod.net/pypy/pypy/-/issues/3757
>
> In case you want to get involved, it's probably not that hard to
> implement and I'd be happy to guide you through it. Let me know!
>
> Cheers,
>
> Carl Friedrich
>
>
> On 31.05.22 08:57, Audrey Dutcher wrote:
>> Hi! Sorry for the delay, I didn't realize I needed to be subscribed to
>> the mailing list to participate in conversations.
>>
>> My use case is that I have a gui application which runs arbitrary
>> tasks as background threads, and needs to provide a cancel button to
>> interrupt them. The tasks are often legacy code and/or are very
>> difficult to find reasonable points to insert checks for interruption.
>>
>> Another use case would be implementing a python shell in a gui. If you
>> want to maintain responsiveness while commands execute, they must be
>> able to run in another thread (or another process, but this is not
>> ideal if the shell is supposed to interact with the internals of your
>> application). Interrupting lines with ctrl-c requires being able to
>> send an exception to worker threads.
>>
>> Hope this helps!
>>
>> Thanks,
>> - Audrey
>> _______________________________________________
>> pypy-dev mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>> https://mail.python.org/mailman3/lists/pypy-dev.python.org/
>> Member address: [email protected]
>
> _______________________________________________
> pypy-dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/pypy-dev.python.org/
> Member address: [email protected]

_______________________________________________
pypy-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pypy-dev.python.org/
Member address: [email protected]