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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:47:00+00:00 2026-05-26T22:47:00+00:00

I’m creating a socket server that will run forever and push files out to

  • 0

I’m creating a socket server that will run forever and push files out to a remote service. The files will be big and many, so creating a threaded script that can help move things along. I have a few questions about how to approach this.

In this setup I will be using the Queue provided by python because it implements thread-safe transactions without any work on my part. I will arbitrarily set the thread count to 10 for now, but will play with it later to find the sweet number.

So which approach should I take:

Should I create 10 threads that are awake while the Queue is populated and sleep while it’s empty? (Consumer producer type deal)

Or should I spawn threads until the max, 10, is reached, then sleep the main program until a thread finishes, then wake up the main thread to spawn one more thread and simply repeat until the Queue is empty.

What are the benefits/drawbacks of either method as well? Thanks.

  • 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-26T22:47:01+00:00Added an answer on May 26, 2026 at 10:47 pm

    Continually creating and terminating threads is expensive, error-prone and best avoided if at all possible on both performance and reliablilty grounds. Micro-managing threads from the ‘main program’ is just, well, just a really bad idea when you can just, well, not do it. Modern languages/environments/libraries are providing thread-pools to try and stop developers doing horrible things like continually creating and destroying threads, waiting for threads to finish with CPU/sleep loops, waiting for threads to finish with DoEvents loops in event-handlers, storing threads in lists and fiddling with them in an attempt to manage them, explicitly terminating threads when it is not necessary and many other nasty practices.

    Go with plan ‘A’. Shove you filePath, remote URI and all else needed, (eg. an error message string:), for the file-push into some object instance and push that onto a blocking producer-consumer queue that has your 10 threads hanging off it. Let the threads manage themselves.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post

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.