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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:44:47+00:00 2026-06-03T21:44:47+00:00

I am working on a realtime data grabber. I have a while True loop,

  • 0

I am working on a realtime data grabber. I have a while True loop, and inside it, I spawn threads that do relatively small tasks (I am querying a 3rd party API over HTTP, and to achieve fast speeds I am querying in parallel).

Every thread takes care of updating a specific data series. This might take 2, 3 or even 5 seconds. However, my while True loop might spawn threads faster than how long it takes for the thread to finish. Hence, I need the spawned threads to wait for their previous threads to finish.

In general, its unpredictable how long it takes for the threads to finish because the threads query an HTTP server…

I was thinking of creating a named semaphore for every thread, and then if a thread spawned for a specific series finds a previous thread working on the same series, it will wait.

The only issue that I can see is a possible backlog of threads..

What is the best solution here? Should I look into things like Celery? I am currently using the threading module.

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-06-03T21:44:48+00:00Added an answer on June 3, 2026 at 9:44 pm

    Another option you could use if you are just requerying the API every time one of your queries returns is an asyncronous framework like Twisted (Their tutorial on Threading). I’m a relative Twisted beginner so there may be better ways of twisting Twisted to your task than this –

    from twisted.internet import reactor, defer
    def simple_task():
        status = query_your_api()
        return status
    
    def repeating_call(status):
        print(status)
        d = threads.deferToThread(simple_task)
        d.addCallback(repeating_call)
    
    data_series = [data1, data2, data3]
    for data in data_series:
        repeating_call('starting everything up')
    
    reactor.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web backend that frequently grabs realtime market data from
I am working on a Python backend web server that grabs realtime data from
I'm working on an idea for a service that uses geocoded data (lat/lng) form
I'm working with a GPS module that is transferring data to my mac over
i currently have highcharts realtime graph working on a browser (e.g. http://www.highcharts.com/demo/dynamic-update ), but
I am working on a project that i want to have a plugin-sandbox like
Preamble: I'm working at heavy-loaded applicaion that produces large data arrays. I wrote the
I am working on an application that will have online and offline components and
I'm working on a realtime imaging system. UI thread: grabs images from a camera
I am working on a program that extracts real time quote for 900+ stocks

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.