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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:00:39+00:00 2026-05-25T13:00:39+00:00

I writing app that connect to a web server (I am the owner of

  • 0

I writing app that connect to a web server (I am the owner of he server) sends information provided by the user, process that information and send result back to the application. The time needed to process the results depends on the user request (from few seconds to a few minutes).

I use a infinite loop to check if the file exist (may be there is a more intelligent approach… may be I could estimated the maximum time a request could take and avoid using and infinite loop)

the important part of the code looks like this

import time
import mechanize

br = mechanize.Browser()
br.set_handle_refresh(False)
proxy_values={'http':'proxy:1234'}
br.set_proxies(proxy_values)


While True:
    try:
        result=br.open('http://www.example.com/sample.txt').read()
        break
    except:
        pass
time.sleep(10)

Behind a proxy the loop never ends, but if i change the code for something like this,

time.sleep(200)
result=br.open('http://www.example.com/sample.txt').read()

i.e. I wait enough time to ensure that the file is created before trying to read it, I indeed get the file 🙂

It seems like if mechanize ask for a file that does not exits everytime mechanize will ask again I will get no file…

I replicated the same behavior using Firefox. I ask for a non-existing file then I create that file (remember I am the owner of the server…) I can not get the file.
And using mechanize and Firefox I can get deleted files…

I think the problem is related to the Proxy cache, I think I can´t delete that cache, but may be there is some way to tell the proxy I need to recheck if the file exists…

Any other suggestion to fix this problem?

  • 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-25T13:00:40+00:00Added an answer on May 25, 2026 at 1:00 pm

    The simplest solution could be to add a (unused) GET parameter to avoid caching the request.

    ie:

    i = 0
    While True:
        try:
            result=br.open('http://www.example.com/sample.txt?r=%d' % i).read()
            break
        except:
            i += 1
        time.sleep(10)
    

    The extra parameter should be ignored by the web application.

    A HTTP HEAD is probably the correct way to do this, see this question for a example.

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

Sidebar

Related Questions

Im writing a facebook-connect app that login user after authenticate session on facebook, question
I'm writing an app that connect to a website and read one line from
I am writing a web app which will allow the user to specify a
I am writing an Android app that initializes a DatagramSocket to connect to a
I'm writing an iPhone app that's using Facebook Connect. While testing, you normally embed
I'm writing a .NET app that connects to a remote hosted SQL Server. Researching
I'm creating an app that has to input/output data from a specific web server
I'm writing an android app that will connect to a REST/JSON webservice. Users will
Im writing an android app that connects to my own Jersey rest client. HTTP
I am writing front end app that connects to a DB and downloads any

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.