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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:04:34+00:00 2026-06-13T09:04:34+00:00

This question is related to A Django Related Question I am running a restlite

  • 0

This question is related to A Django Related Question

I am running a restlite WSGI app with wsgiref.simple_server. I have this set up so that before the serve_forever() method gets calls it initializes some objects. Most relevantly these classes.

import Queue
import threading
import Deployer
import ParallelRunner
import sys
import subprocess

class DeployManager:
def __init__(self):
    self.inputQueue = Queue.Queue() 
    self.workerThread = DeployManagerWorkerThread(self.inputQueue)
    self.workerThread.start()   
def addDeployJob(self, appList):
    self.inputQueue.put(appList)  #make sure this handles the queue being full
def stopWorker(self):
    self.workerThread.running = False
def __del__(self):
    self.stopWorker()

class DeployManagerWorkerThread(threading.Thread):
def __init__(self, Queue):
    super(DeployManagerWorkerThread, self).__init__()
    self.queue = Queue
    self.running = True
    self.deployer = Deployer.Deployer()
    self.runner = ParallelRunner.ParallelRunner()

def run(self):
    while self.running:
        try:
            appList = self.queue.get(timeout = 10) #This blocks until something is in the queue
            sys.stdout.write('Got deployment job\n')
                            command = "ssh " + server.sshUsername + "@" + server.hostname + "" + " -i " + server.sshPrivateKeyPath + r" 'bash -s' < " + pathToScript 
                            self.process = subprocess.Popen(command,shell=True ,stdin=subprocess.PIPE, stdout=subprocess.PIPE)
            output = process.communicate()[0]
            sys.stdout.write(output + '\n')
        except Queue.Empty:
            pass
    sys.stdout.write('DeployManagerWorkerThread exiting\n')

The restlite request is set up like this

@restlite.resource
def deployAll():
def POST(request, entity):
    GlobalDeployManager.addDeployJob(GlobalAppList) #TODO should runners be configurable at start up
    #print output                                               #or on a run by run basis
    return 'Job added'
return locals()

Which would put an entry into the queue which the workerThread would then grab and start processing. However the call to POpen always hangs I stepped into this and it appears it hangs at a call to os.fork() which will “freeze” the server. When the thread gets to the POpen command the main thread is at the line where it is accepting new requests. I believe the server is using epoll for this. If there are multiple jobs in the queue i can press control-C at the console the server is running in and the main thread will exit (Not be at the line which is waiting for requests) and then the thread will be able to run will work as expected and then close. Any ideas?

  • 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-13T09:04:36+00:00Added an answer on June 13, 2026 at 9:04 am

    I eventually figured this out… I needed to create the threads object in the run method. I accidentally forgot that the init method was called from the main thread and then the new thread itself never executes init.

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

Sidebar

Related Questions

This question is related to awk, I suppose. I have no experience with awk.
This question is related to database/RDBMS where i have little knowledge regarding performance and
I took this sample code here : Django ORM: Selecting related set polls =
This is related to this question: Django return json and html depending on client
Although this is django related, it's really just a general, programming efficiency question. I
I asked this question before, but I received no solutions, so I have tried
This question is more Python related than Django related. I want to test write
This question is related to (but perhaps not quite the same as): Does Django
This question assumes that the python package I want to install is a django
this question has been answered several times and i have seen almost all related

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.