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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:23:49+00:00 2026-05-25T19:23:49+00:00

In Windows, that is. I think the answer to this question is that I

  • 0

In Windows, that is.

I think the answer to this question is that I need to create a Windows service. This seems ludicrously heavyweight for what I am trying to do.

I’m just trying to slap together a little prototype here for my manager, I’m not going to be responsible for productizing it… in fact, it may never even BE productized; it might just be something that a few researchers play around with.

I have a CGI script that receives a file for upload, stores it to a temporary location, then launches a background process to do some serious number-crunching on the file. Then some Javascript stuff sits around calling other CGI scripts to check on the status and update the page as needed.

All of this works, except the damn web server won’t close the connection as long as the subrocess is running. I’ve done some searching, and it appears the answer on Unix is to make it a daemon, but I’m stuck on Windows right now and I guess the answer there is to make it a Windows service?!? This seems incredibly heavyweight to just, you know, launch a damn process and then close the server connection.

That’s really the only way?

Edit: Okay, found a nifty little hack over here (the choice (3) that the guy gives):
How to completely background a process in Perl CGI under IIS

I was able to modify this to make it even simpler, and although this is a klugey solution, it is perfect for the quick-and-dirty little prototype I am trying to make.

So I initially had my main script doing this:

subprocess.Popen("python.exe","myscript.py","arg1","arg2")

Which doesn’t work, as I’ve described. Instead, I now have my main script emit this little bit of Javascript which runs after the document is fully loaded:

$("#somecrap").load("launchBackgroundProcess.py", {arg1:"foo",arg2:"bar"});

And then launchBackgroundProcess.py does the subprocess.Popen.

This solution would never scale, since it still leaves the browser connection open during the entire time the background task is running. But since this little thinger I am whipping up might someday have two simultaneous users at most (even then I doubt it) resources are not a concern. This allows the user to see the main page and get the Javascript updates even though there is still an http connection hanging open for no good reason.

Thanks for the answers! If I’m ever asked to productize this, I’ll take at the resources Profane recommends.

  • 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-25T19:23:50+00:00Added an answer on May 25, 2026 at 7:23 pm

    If you haven’t much experience with windows programming and don’t wish to peruse the MSDN docs– I don’t blame you– you may want to try to pick up a copy of Mark Hammond’s cannonical guide to all things python and windows. It somehow never goes out-of-date on many of these sorts of recurring questions. Instead of launching the process with the every-platform solution, you’d probably be better off using the win32process module. Chapter 17 of the Hammond book covers this extensively, but you could probably get all you need by downloading the pywin ide (I think it comes bundled in the windows extensions which you can download from pypi), and looking through the help docs it has on python’s windows’ api. Here’s an example of using the api, from a project I was working on recently. It may in fact do some of what you want with a little adaptation. You’d probably want to focus on CreationFlags. In particular, win32process.DETACHED_PROCESS is “often used to execute console programs in the background.” Many other flags are available and conveniently wrapped however.

        if subprocess.mswindows:
            su=subprocess.STARTUPINFO()
            su.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
        process = subprocess.Popen(['program', 'flag', 'flag2'], bufsize=-1,
                  stdout=subprocess.PIPE, startupinfo=su)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create applications in windows that has complete portability (within windows OSes
I have a long URL on a web page in Windows that I need
I am trying to build a downloaded Python app on Windows that uses Pygame.
I'm trying to build an application from source in windows that requires some Unix
This is sufficiently important to me that I'm opening the question up to a
I need an answer to the following question to help understand what approach I
I almost have an answer to my last question , but I need help.
I have this question you probably know the answer... My app is already functional
My apologies for the extremely basic question, I think I know the answer but
This question is not about timing something accurately on Windows (XP or better), but

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.