Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3671646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:30:45+00:00 2026-05-19T02:30:45+00:00

I have a GUI program which should also be controllable via CLI (for monitoring).

  • 0

I have a GUI program which should also be controllable via CLI (for monitoring). The CLI is implemented in a while loop using raw_input.
If I quit the program via a GUI close button, it hangs in raw_input and does not quit until it gets an input.

How can I immediately abort raw_input without entering an input?

I run it on WinXP but I want it to be platform independent, it should also work within Eclipse since it is a developer tool. Python version is 2.6.

I searched stackoverflow for hours and I know there are many answers to that topic, but is there really no platform independent solution to have a non-blocking CLI reader?

If not, what would be the best way to overcome this problem?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:30:45+00:00Added an answer on May 19, 2026 at 2:30 am

    That’s not maybe the best solution but you could use the thread module which has a function thread.interrupt_main(). So can run two thread : one with your raw_input method and one which can give the interruption signal. The upper level thread raise a KeyboardInterrupt exception.

    import thread
    import time
    
    def main():
        try:
            m = thread.start_new_thread(killable_input, tuple())
            while 1:
                time.sleep(0.1) 
        except KeyboardInterrupt:
            print "exception" 
    
    def killable_input():
        w = thread.start_new_thread(normal_input, tuple())
        i = thread.start_new_thread(wait_sometime, tuple())
    
    
    def normal_input():
        s = raw_input("input:")
    
    
    def wait_sometime():
        time.sleep(4) # or any other condition to kill the thread
        print "too slow, killing imput"
        thread.interrupt_main()
    
    if __name__ == '__main__':
        main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a GUI program using MVC which should look like this.. alt
I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
Does MSTest have standalone GUI similar to nUnit that lets me use it and
My use case is very simple : I have a GUI application, and inside
I have a large GUI project that I'd like to port to Linux. What
I have a swing gui with a tabbed pane in the north. Several key
I have a simple GUI component written in Java. The class draws an analog
I have my main GUI thread, and a second thread running inside it's own
I have a fat GUI that it getting fairly complex, and I would like
I want to have in my GUI capability for scale, rotate and crop images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.