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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:51:46+00:00 2026-05-13T05:51:46+00:00

I’ve got a Python CGI script that pulls data from a GPS service; I’d

  • 0

I’ve got a Python CGI script that pulls data from a GPS service; I’d like this information to be updated on the webpage about once every 10s (the max allowed by the GPS service’s TOS). But there could be, say, 100 users viewing the webpage at once, all calling the script.

I think the users’ scripts need to grab data from a buffer page that itself only upates once every ten seconds. How can I make this buffer page auto-update if there’s no one directly viewing the content (and not accessing the CGI)? Are there better ways to accomplish this?

  • 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-13T05:51:47+00:00Added an answer on May 13, 2026 at 5:51 am

    Cache the results of your GPS data query in a file or database (sqlite) along with a datetime.

    You can then do a datetime check against the last cached datetime to initiate another GPS data query.

    You’ll probably run into concurrency issues with cgi and the datetime check though…

    To get around concurrency issues, you can use sqlite, and put the write in a try/except.
    Here’s a sample cache implementation using sqlite.

    import datetime
    import sqlite3 
    
    class GpsCache(object):
        db_path = 'gps_cache.db'
        def __init__(self):
            self.con = sqlite3.connect(self.db_path)
            self.cur = self.con.cursor()
    
        def _get_period(self, dt=None):
            '''normalize time to 15 minute periods'''
            if dt.minute < 15:
               minute_period = 0
            elif 15 <= dt.minute < 30:
               minute_period = 15
            elif 30 <= dt_minute < 45: 
               minute_period = 30
            elif 45 <= dt_minute:
               minute_period = 25
            period_dt = datetime.datetime(year=dt.year, month=dt.month, day=dt.day, hour=dt.hour, minute=minute_period)
            return period_dt
    
        def get_cache(dt=None):
            period_dt = self._get_period(dt)
            select_sql = 'SELECT * FROM GPS_CACHE WHERE date_time = "%s";' % period_dt.strftime('%Y-%m-%d %H:%M')
            self.cur.execut(select_sql)
            result = self.cur.fetchone()[0]
            return result
    
    
        def put_cache(dt=None, data=None):
            period_dt = self._get_period(dt)
            insert_sql = 'INSERT ....'  # edit to your table structure
            try:
                self.cur.execute(insert_sql)
                self.con.commit()
            except sqlite3.OperationalError:
                # assume db is being updated by another process with the current resutls and ignore
                pass
    

    So we have the cache tool now the implementation side.

    You’ll want to check the cache first then if it’s not ‘fresh’ (doens’t return anything), go grab the data using your current method. Then cache the data you grabbed.
    you should probably organize this better, but you should get the general idea here.

    Using this sample, you just replace your current calls to ‘remote_get_gps_data’ with ‘get_gps_data’.

    from gps_cacher import GpsCache
    
    def remote_get_gps_data():
        # your function here
        return data
    
    def get_gps_data():
        data = None
        gps_cache = GpsCache()
        current_dt = datetime.datetime.now()
        cached_data = gps_cache.get_cache(current_dt)    
        if cached_data:
            data = cached_data
        else:
            data = remote_get_gps_data()
            gps_cache.put_cache(current_dt, data)
        return data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 427k
  • Answers 427k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'd suggest you brush up on some basic C materials… May 15, 2026 at 12:48 pm
  • Editorial Team
    Editorial Team added an answer If you can run select based stored procedures, and not… May 15, 2026 at 12:48 pm
  • Editorial Team
    Editorial Team added an answer Yes, and I'd do it like this... window.onload = function… May 15, 2026 at 12:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.