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 7605335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:08:34+00:00 2026-05-31T00:08:34+00:00

Running Python 3.2 on Windows 7 Pro 64 Bit. OK I have some very

  • 0

Running Python 3.2 on Windows 7 Pro 64 Bit.

OK I have some very basic code here that’s just not behaving like I want it to.

#!/usr/bin/env python

import time
import threading

def shutdown(sleeptime):
    time.sleep(sleeptime)
    print('I have executed')

threading.Thread(target = shutdown(5)).start()
print('I go first')

The idea being that the script runs, it starts a thread which sleeps for 5 seconds then prints out ‘I have executed’. In the meantime the script keeps going and prints out ‘I go first’.

What actually happens is that the script starts the thread, everything waits for it to finish and then it continues. Clearly I’m not doing the threading correctly but I’m having trouble finding simple examples of threading with Python 3.

  • 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-31T00:08:36+00:00Added an answer on May 31, 2026 at 12:08 am

    Your statement:

    threading.Thread(target = shutdown(5)).start()
    

    can be equivalently written as:

    x = shutdown(5)
    threading.Thread(target = x).start()
    

    I.e. you are calling shutdown first, then passing the result to the Thread constructor.

    You need to pass your function, without calling it, and your argument list, to Thread separately:

    threading.Thread(target = shutdown, args = (5,)).start()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Jenkins running a python script that makes some SVN calls, my problem
We have a server running Windows 7 Pro. I have several Python script I'd
Hey I have a windows server running python CGI scripts and I'm having a
I am running a windows machine have installed Python 2.5. I also used the
Running Python 2.5 on Windows XP SP2. When I run a Python script that
When Python is running under Windows, time.localtime does not report the correct time if
I would like to install bitarray in Windows running python 2.6. I have mingw32
I'm running python 2.6 with latest IPython on Windows XP SP3, and I have
I'm running a Python script on Windows, and I've noticed that even though the
I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer

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.