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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:32:16+00:00 2026-05-24T01:32:16+00:00

Erm… i promise i searched thoroughly the web for this and couldn’t find a

  • 0

Erm… i promise i searched thoroughly the web for this and couldn’t find a satisfatory answer so >.<

I’m trying to make a ‘controller’ for my python app, i mean, it should be executed and then spawn the server, wait to pickup exit signals and if necessary, restart the script.

This code is pretty messy but that’s what i’ve come with so far… It always returns with unrecognized exitSignal 1 and won’t even spawn the server process! Can someone give me a light please?

#Server controller version 0.1
import os
import time
from datetime import datetime

Log = file("C:/Users/Admin/Desktop/Python/Server/WIP.log", 'w')

def runServer():
    exitSignal = os.spawnv(os.P_WAIT, 'C:/Python2.7/python.exe', ['python.exe',         'C:/Users/Admin/Desktop/Python/Server/WIP.py'])
    print str(datetime.today())+" - Server started"
    Log.write("\n"+str(datetime.today())+" - Server started")

    if exitSignal == "0":
        print str(datetime.today())+" - Server exited succesfully."
        Log.write("\n"+str(datetime.today())+" - Server exited succesfully.")

    elif exitSignal == "10":
        print str(datetime.today())+" - Rebooting server immediately."
        Log.write("\n"+str(datetime.today())+" - Rebooting server immediately.")
        runServer()

    elif exitSignal == "11":
        print str(datetime.today())+" - Rebooting server in 5 minutes."
        Log.write("\n"+str(datetime.today())+" - Rebooting server in 5 minutes.")
        time.sleep(300)
        runServer()
        print str(datetime.today())+" - Server rebooted."
        Log.write("\n"+str(datetime.today())+" - Server rebooted.")

    else:
        print str(datetime.today())+" - Unrecognized exitSignal code: %s" % str(exitSignal)
        Log.write("\n"+str(datetime.today())+" - Unrecognized exitSignal code: %s" % str(exitSignal))

if __name__ == "__main__":
    print str(datetime.today())+" - Controller started."
    Log.write("\n"+str(datetime.today())+" - Controller started")
    runServer()

Sorry for the messy code! (=^,^=)

  • 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-24T01:32:18+00:00Added an answer on May 24, 2026 at 1:32 am

    As described here, os.spawnv is a deprecated method, you should use the subprocess module.

    Apart this, if you always got 1 returned and no process spawned, maybe it is due to a bad path to the server code or a bad code for the server part. What happen if you launch the server manually ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't find info bout this anywhere on the internet. I got a list of
Reading this question , in the first comment, @Cody Gray says: Erm, you know
Erm, why this don`t work, iv used similar code like this for my site
Erm, that's it!...
I'm trying to write a MySQL script that creates several tables. I have: CREATE
Ok so I have this storedproc in my SQL 2008 database (works in 2005
Erm - what the question said. It's something I keep hearing about, but I've
I know that that is not a question... erm anyway HERE is the question.
I need to abstract some behavioural code and have a problem trying to reference
I'm just trying to format a haml-generated (text) mailer template, and I'm having 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.