Ah!
On 10/19/07, Dino Viehland <[EMAIL PROTECTED]> wrote:
>
> And we implement that using Thread.Abort (which is the only way we really
> have to interrupt a thread at an arbitrary point in time) J When the user
> catches it they'll see it as a KeyboardInterruptException, and we'll do the
> right thing for Thread.ResetAbort().
>
>
>
> If you want to get the exact behavior we cause with Ctrl-C it's actually:
>
>
>
> import clr
>
> clr.AddReference('Microsoft.Scripting')
>
> from Microsoft.Scripting.Shell import KeyboardInterruptException
>
> main.Abort(KeyboardInterruptException(""))
>
>
>
> in v1.x it's:
>
>
>
> import clr
>
> clr.AddReference('IronPython')
>
> from IronPython.Runtime.Exceptions import PythonKeyboardInterruptException
>
> main.Abort(PythonKeyboardInterruptException(""))
>
>
>
> and then the user can catch it as a they'd catch a normal keyboard
> interrupt. I think the only reason we don't have this implemented by
> default is that in some situations (e.g. outside the console) we won't
> actually know what the "main" thread is.
>
>
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Curt Hagenlocher
> *Sent:* Friday, October 19, 2007 10:17 AM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] thread.interrupt_main() not implemented
>
>
>
> thread.interrupt_main has somewhat different semantics than Thread.Abort;
> it basically triggers a keyboard interrupt on the main thread -- this is, of
> course, an exception that can be caught and handled by user code on that
> thread.
>
>
>
> On 10/19/07, *Dino Viehland* <[EMAIL PROTECTED]> wrote:
>
> I think you could work around this by remembering the main .NET thread
> and calling Abort on it:
>
>
>
> from System import Threading
>
> main = Thread.CurrentThread
>
>
>
> # and then later on…
>
>
>
> main.Abort()
>
>
>
> But I'd suggest that interrupting a thread at an arbitrary point is a
> little dangerous (as it may have some state which isn't entirely consistent
> that it's trying to update).
>
>
>
>
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Clems no
> *Sent:* Friday, October 19, 2007 8:37 AM
> *To:* [email protected]
> *Subject:* [IronPython] thread.interrupt_main() not implemented
>
>
>
> Hello,
>
> When i want to use thread.interrupt_main() in iron python script, i've got
> this error:
> NotImplementedError: interrupt_main not implemented
>
> Is there an equivalent in ironpython?
>
> Thanks,
>
> cbr.
>
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com