473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

limit Python CGI's frequency of calls to an external database?

7
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? Database? Server-side cron (these would be limited by my host's TOS though..)? I'm very new to these topics but these are ideas I've heard. Thanks.
Dec 16 '09 #1
3 1613
Glenton
391 Expert 256MB
I've never really done this kind of thing before.

But why do you need to update the buffer when no-one's viewing it?

If you didn't have to, then you just include a time stamp in the buffered data, and then when the user makes a call you check if you're within 10 seconds of that time stamp. If so, you return the buffered data, if not, you update the buffer, and return the new data.

If you need the buffer to be updated regardless (in which case your user's call would just involve getting whatever the latest data is), then you probably need to look at a background thread.

But I'm afraid this might be the blind leading the blind here...

Please let us know how you're getting on.
Dec 17 '09 #2
mab43
7
Glenton, thanks, you're right; there's certainly no need to update the buffer when there are no viewers.

Are there concurrency issues if multiple users are trying to read/edit a buffer file simultaneously? User number would be low and the file size would also be quite low, so maybe not?
Dec 17 '09 #3
mab43
7
I ultimately did as Glenton suggested: had the CGI script check to see if ten seconds had elapsed since the last data file-write, if not, get new GPS data and update the data file with a timestamp.

My code is posted as part of a bus-tracking project here.
Dec 26 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: @(none) | last post by:
Facts: (1) I don't know anything about data bases (2) I don't have much time to learn about them (but I do have SOME time) (3) I need to store (and retrieve) thousands of pages for a wiki,...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
1
by: chris.levis | last post by:
All: I have written a Python webapp under MS IIS 5.0 that does the following: -Does a CVS checkout of a particular bit of xml -Gets a list of valid cvs tags for that xml file -Based on user...
7
by: Ajar | last post by:
I want to write a program which will automatically login to my ISPs website, retrieve data and do some processing. Can this be done? Can you point me to any example python programs which do similar...
5
by: mab43 | last post by:
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.