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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:12:34+00:00 2026-05-26T11:12:34+00:00

I have a python application , to be more precise a Network Application that

  • 0

I have a python application , to be more precise a Network Application that can’t go down this means i can’t kill the PID since it actually talks with other servers and clients and so on … many € per minute of downtime , you know the usual 24/7 system.

Anyway in my hobby projects i also work a lot with WSGI frameworks and i noticed that i have the same problem even during off-peak hours.

Anyway imagine a normal server using TCP/UDP ( put here your favourite WSGI/SIP/Classified Information Server/etc).

Now you perform a git pull in the remote server and there goes the new python files into the server (these files will of course ONLY affect the data processing and not the actual sockets so there is no need to re-raise the sockets or touch in any way the network part).

I don’t usually use File monitors since i prefer to use SIGNAL to wakeup the internal app updater.

Now imagine the following code

from mysuper.app import handler

while True:
  data = socket.recv()
  if data:

    socket.send(handler(data))

Lets imagine that handler is a APP with DB connections, cache connections , etc.

What is the best way to update the handler.

Is it safe to call reload(handler) ?

Will this break DB connections ?

Will DB Connections survive to this restart ?

Will current transactions be lost ?

Will this create anti-matter ?

What is the best-pratice patterns that you guys usually use if there are any ?

  • 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-26T11:12:35+00:00Added an answer on May 26, 2026 at 11:12 am

    It’s safe to call reload(handler).

    Depends where you initialize your connections. If you make the connections inside handler(), then yes, they’ll be garbage collected when the handler() object falls out of scope. But you wouldn’t be connecting inside your main loop, would you? I’d highly recommend something like:

    dbconnection = connect(...)
    while True:
        ...
        socket.send(handler(data, dbconnection))
    

    if for no other reason than that you won’t be making an expensive connection inside a tight loop.

    That said, I’d recommend going with an entirely different architecture. Make a listener process that does basically nothing more than listen for UDP datagrams, sends them to a messaging queue like RabbitMQ, then waits for the reply message to send the results back to the client. Then write your actual servers that get their requests from the messaging queue, process them, and send a reply message back.

    If you want to upgrade the UDP server, launch the new instance listening on another port. Update your firewall rules to redirect incoming traffic to the new port. Reload the rules. Kill the old process. Voila: seamless cutover.

    The real win is from uncoupling your backend. Since multiple processes can listen for the same messages from your frontend “proxy” service, you can run several in parallel – on different machines, if you want to. To upgrade the backend, start a new instance then kill the old one so that there’s no time when at least one instance isn’t running.

    To scale your proxy, have multiple instances running on different ports or different hosts, and configure your firewall to randomly redirect incoming datagrams to one of the proxies.

    To scale your backend, run more instances.

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

Sidebar

Related Questions

I have strings in my python application that look this way: test1/test2/foo/ Everytime I
I have a python application that relies on a file that is downloaded by
Long story short, I have a substantial Python application that, among other things, does
We have a Linux application that makes use of OpenSSL's Python bindings and I
I want to run javascript/Python/Ruby inside my application. I have an application that creates
Let's say we have a system like this: ______ { application instances ---network--- (______)
We have a Python application that polls directories using threads and inotify watchers. We
Background : I have a small Python application that makes life for developers releasing
I have been trying to track down weird problems with my mod_wsgi/Python web application.
Say that I have the Python code: someString = file(filename.jpg).read() How can I replicate

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.