Keyboard interrupts, Idle vs. SciTE

Discussion in 'Python' started by John Ladasky, Nov 2, 2006.

  1. John Ladasky

    John Ladasky Guest

    Hi there.

    The following minimal code in Python 2.3.4 works under Idle v. 1.0.3,
    but not under SciTE v. 1.66:

    from time import sleep
    try:
    while True:
    sleep(0.25)
    print ".",
    except KeyboardInterrupt:
    print "\nKeyboard interrupt received. Exiting program.\n\n"


    Under SciTE, I do not get my "exiting program" message. Instead, I get
    the standard SciTE abort message:


    >Process failed to respond; forcing abrupt termination...
    >Exit code: 1



    I much prefer the SciTE environment to Idle. Is there any way that I
    can rewrite my program to restore the keyboard interrupt function under
    SciTE? Alternately, is there some setting that I can change in SciTE
    to accomplish the same effect?

    Thanks for your input!


    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Ladasky Home Solar, Inc.: blowing sunshine up your |
    | power grid since March 24, 2005. Fiat lux! |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Uptime Downtime kWh generated kWh consumed |
    | 584 days 6.5 hours 10953 10982 |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
     
    John Ladasky, Nov 2, 2006
    #1
    1. Advertising

  2. John Ladasky

    Neil Hodgson Guest

    John Ladasky:

    > Under SciTE, I do not get my "exiting program" message. Instead, I get
    > the standard SciTE abort message:
    >
    >
    >> Process failed to respond; forcing abrupt termination...
    >> Exit code: 1

    >
    >
    > I much prefer the SciTE environment to Idle. Is there any way that I
    > can rewrite my program to restore the keyboard interrupt function under
    > SciTE? Alternately, is there some setting that I can change in SciTE
    > to accomplish the same effect?


    This is on Windows - its generally a good idea to say which platform
    you are using. SciTE runs Python as an external process and tries to
    interrupt by writing a Ctrl+Z to the input of the running process which
    works for many interactive programs. If that fails, it calls
    TerminateProcess and displays the message you see.

    There is some dead code to call
    GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT... in scite/src/SciTEWin.cxx
    that you could try to enable and rebuild SciTE.

    Idle may be running the code in-process but even if it is running it
    out of process in debugging mode, it still has much more knowledge of
    the execution environment. SciTE uses the same code for running Python
    as for running grep or javac.

    Neil
     
    Neil Hodgson, Nov 2, 2006
    #2
    1. Advertising

  3. John Ladasky

    robert Guest

    John Ladasky wrote:
    > Hi there.
    >
    > The following minimal code in Python 2.3.4 works under Idle v. 1.0.3,
    > but not under SciTE v. 1.66:
    >
    > from time import sleep
    > try:
    > while True:
    > sleep(0.25)
    > print ".",
    > except KeyboardInterrupt:
    > print "\nKeyboard interrupt received. Exiting program.\n\n"
    >
    >
    > Under SciTE, I do not get my "exiting program" message. Instead, I get
    > the standard SciTE abort message:
    >
    >
    >> Process failed to respond; forcing abrupt termination...
    >> Exit code: 1

    >
    >
    > I much prefer the SciTE environment to Idle. Is there any way that I
    > can rewrite my program to restore the keyboard interrupt function under
    > SciTE? Alternately, is there some setting that I can change in SciTE
    > to accomplish the same effect?


    Use PythonWin on Windows. It is based on the same Scintilla editor, but provides real interaction and inline script execution capabs, debugging ...
    SciTE catches only stdout ( sometimes :) ) etc.

    robert
     
    robert, Nov 3, 2006
    #3
  4. John Ladasky

    John Ladasky Guest

    Thanks for the SciTE info, Neil.

    Yes, it was silly of me to forget to state that I'm using Win32.
    Normally, when I post to comp.lang.python, I remember to include that
    fact... :^P

    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Ladasky Home Solar, Inc.: blowing sunshine up your |
    | power grid since March 24, 2005. Fiat lux! |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Uptime Downtime kWh generated kWh consumed |
    | 584 days 6.5 hours 10953 10982 |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
     
    John Ladasky, Nov 3, 2006
    #4
  5. John Ladasky

    John Ladasky Guest

    Thanks Robert, I just poked around and found a PythonWin web page:

    http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/html/pythonwin/readme.html

    >From other links it appears that SciTE was based on PythonWin, and not

    the other way around. For people coding in other languages besides
    Python, switching from SciTE to PythonWin might be a step backward.
    But probably not for me. I'll give it a try.

    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Ladasky Home Solar, Inc.: blowing sunshine up your |
    | power grid since March 24, 2005. Fiat lux! |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
    | Uptime Downtime kWh generated kWh consumed |
    | 584 days 6.5 hours 10953 10982 |
    +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
     
    John Ladasky, Nov 3, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D.Sn

    Interrupts in VB (API)

    D.Sn, Jan 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,760
    Willy Denoyette [MVP]
    Jan 12, 2004
  2. Ciaran
    Replies:
    12
    Views:
    6,063
    Frank van Eijkelenburg
    Feb 27, 2004
  3. guru10
    Replies:
    1
    Views:
    1,207
  4. Victor Bazarov

    Keyboard interrupts

    Victor Bazarov, Mar 28, 2005, in forum: C++
    Replies:
    8
    Views:
    8,774
    Ioannis Vranos
    Mar 29, 2005
  5. Alex Young
    Replies:
    6
    Views:
    180
    Alex Young
    Oct 5, 2006
Loading...

Share This Page