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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:22:44+00:00 2026-05-25T23:22:44+00:00

from multiprocessing import Process a=Process(target=worker, args=()) a.start() I am making a multiple worker-process app

  • 0
from  multiprocessing import Process    
a=Process(target=worker, args=())
a.start()

I am making a multiple worker-process app (don’t laugh yet) in which each worker can gracefully reload. Whenever the code is updated, new requests are served by new worker processes with the new code. This is such that

  1. A newly launched thread contains updated code
  2. ensure that no requests are dropped

I already made a worker that listens:

  1. serves requests when it gets aa request signal
  2. kills itself when the next signal is a control signal

I did it in zeromq. The clients connect to this server using zeromq. The clients do not interact by HTTP.


What is a good way to reload the code? Can you explain a scheme that is simple and stupid enough to be robust?


What I have in mind/ can do

Launch a thread within the main process that iterates:

  1. Signal every worker process to die
  2. Launch new worker processes

But this approach will drop (I configured it that way) requests between the death of the last old worker and the spawning of the first new worker.


And no, I am not a college student. The "homework" just means a curiosity-driven pursuit.

  • 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-25T23:22:45+00:00Added an answer on May 25, 2026 at 11:22 pm

    Reloading code in python is a notoriously difficult problem.

    Here’s how I would deal with it:

    • at server startup, listen on your HTTP port (but do not start accepting connections)
    • Use multiprocessing or some such to create some worker processes; this should happen after the socket starts listening so that the subprocesses inherit the socket.
    • each worker can then accept connections and service requests.
    • when the parent process learns that it should reload, it shuts down the listening socket.
    • when a worker tries to accept a closed socket, it recieves a socket.error exception, and should terminate
    • the parent process can start a new main process (as in subprocess.Popen(sys.argv)) the new process can start accepting connections immediately.
    • the old process can now wait for the child workers to finish; the children cannot accept new connections (since the listening socket is shutdown). Once all child process have finished handling in-flight requests and closed, the parent process can also terminate.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't understand why this simple code # file: mp.py from multiprocessing import Process
from multiprocessing import Process # c is a container p = Process(target = f,
I'm trying to understand multiprocessing in python. from multiprocessing import Process def multiply(a,b): print(a*b)
I was working the following example from Doug Hellmann tutorial on multiprocessing: import multiprocessing
I'm trying to get output from a python multiprocessing Process displayed in a Tkinter
I have picked a snippet from http://docs.python.org/library/multiprocessing.html#multiprocessing-examples import multiprocessing def queue_func(queue): for i in
$ python2.6 -c 'from multiprocessing.queues import SimpleQueue' $ python2.7 -c 'from multiprocessing.queues import SimpleQueue'
I'm looking for a fast way for multiple processes (in multiprocessing.Pool()) to read from
Consider the following program: import Queue from multiprocessing import Queue as Q from multiprocessing
I tried to copy this example from this Multiprocessing lecture by jesse noller (as

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.