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

  • SEARCH
  • Home
  • 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 8814993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:15:55+00:00 2026-06-14T04:15:55+00:00

What is the method to delay the keyboard interrupt for an important part of

  • 0

What is the method to delay the keyboard interrupt for an important part of the program (in my example in a cycle).

I want to download (or save) many files, and if it takes too long, I want to finish the program, when the recent file have been downloaded.

Need I to use the signal module as in the answer for Capture keyboardinterrupt in Python without try-except? Can I set a global variable to True with the signal handler and break the cycle if it is True?

The original cycle is:

for file_ in files_to_download:
    urllib.urlretrieve("".join(baseurl, file_), os.path.join(".", file_)) 
  • 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-06-14T04:15:56+00:00Added an answer on June 14, 2026 at 4:15 am

    Something like the following may work:

    # at module level (not inside class or function)
    finish = False
    def signal_handler(signal, frame):
        global finish
        finish = True
    
    signal.signal(signal.SIGINT, signal_handler)
    
    # wherever you have your file downloading code (same module)
    for file_ in files_to_download:
        if finish:
            break
        urllib.urlretrieve("".join(baseurl, file_), os.path.join(".", file_)) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Method M takes 2 parameters, P1 and P2. P2 is a delegate. I want
Is there ANY method to delay the loading of 3rd party JavaScript files until
I want to delay things like the css from happening but this method wont
I have a method that takes several params, I need to delay a portion
I want to delay a prepared method call (prepared= all parameters already set) for
How can I call a method after a short delay? (For example, after resignFirstResponder
I know in jQuery 1.4.x there is a method delay(). We can use it
I know there is a method like this : setTimeout(functionA();,1250); That can delay my
Let say I have an async method: public async Task Do() { await Task.Delay(1000);
I'm trying to call a method after some delay. I know there is a

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.