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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:58:38+00:00 2026-05-17T18:58:38+00:00

I am writing an update application in Python 2.x. I have one thread (ticket_server)

  • 0

I am writing an update application in Python 2.x. I have one thread (ticket_server) sitting on a database (CouchDB) url in longpoll mode. Update requests are dumped into this database from an outside application. When a change comes, ticket_server triggers a worker thread (update_manager). The heavy lifting is done in this update_manager thread. There will be telnet connections and ftp uploads performed. So it is of highest importance that this process not be interrupted.

My question is, is it safe to spawn update_manager threads from the ticket_server threads?

The other option might be to put requests into a queue, and have another function wait for a ticket to enter the queue and then pass the request off to an update_manager thread. But, Id rather keeps tings simple (Im assuming the ticket_server spawning update_manager is simple) until I have a reason to expand.

# Here is the heavy lifter
class Update_Manager(threading.Thread):
    def __init__(self)
        threading.Thread.__init__(self, ticket, telnet_ip, ftp_ip)
        self.ticket = ticket   
        self.telnet_ip = telnet_ip
        self.ftp_ip = ftp_ip


    def run(self):
        # This will be a very lengthy process.
        self.do_some_telnet()
        self.do_some_ftp()

    def do_some_telnet(self)
        ...

    def do_some_ftp(self)
        ...

# This guy just passes work orders off to Update_Manager
class Ticket_Server(threading.Thread):
    def __init__(self)
        threading.Thread.__init__(self, database_ip)
        self.database_ip

    def run(self):
        # This function call will block this thread only.
        ticket = self.get_ticket(database_ip)

        # Here is where I question what to do.
        # Should I 1) call the Update thread right from here...
        up_man = Update_Manager(ticket)
        up_man.start

        # Or should I 2) put the ticket into a queue and let some other function
        # not in this thread fire the Update_Manager. 


    def get_ticket()
    # This function will 'wait' for a ticket to get posted. 
    # for those familiar with couchdb:
        url = 'http://' + database_ip:port + '/_changes?feed=longpoll&since=' + update_seq
        response = urllib2.urlopen(url)

This is just a lot of code to ask which approach is the safer/more efficient/more pythonic
Im only a few months old with python so these question get my brain stuck in a while loop.

  • 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-17T18:58:38+00:00Added an answer on May 17, 2026 at 6:58 pm

    The main thread of a program is a thread; the only way to spawn a thread is from another thread.

    Of course, you need to make sure your blocking thread is releasing the GIL while it waits, or other Python threads won’t run. All mature Python database bindings will do this, but I’ve never heard of couchdb.

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

Sidebar

Related Questions

I am current writing an application that will require multiple inserts, updates and deletes
When writing destructive queries (e.g., DELETE or UPDATE) in SQL Server Management Studio I
I'm writing a script in python which basically queries WMI and updates the information
I am writing a Python utility that needs to parse a large, regularly-updated CSV
Writing my first Linq application, and I'm trying to find the best way to
We perform updates of large text files by writing new records to a temp
Writing some test scripts in IronPython, I want to verify whether a window is
Writing the code for the user authentication portion of a web site (including account
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws 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.