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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:25:56+00:00 2026-05-11T19:25:56+00:00

I have been trying to track down weird problems with my mod_wsgi/Python web application.

  • 0

I have been trying to track down weird problems with my mod_wsgi/Python web application. I have the application handler which creates an object and calls a method:

def my_method(self, file):
    self.sapi.write("In my method for %d time"%self.mmcount)
    self.mmcount += 1

    # ... open file (absolute path to file), extract list of files inside
    # ... exit if file contains no path/file strings
    for f in extracted_files:
        self.num_files_found += 1
        self.my_method(f)

At the start and end of this, I write

obj.num_files_found

To the browser.

So this is a recursive function that goes down a tree of file-references inside files. Any references in a file are printed and then those references are opened and examined and so on until all files are leaf-nodes containing no files. Why I am doing this isn’t really important … it is more of a pedantic example.

You would expect the output to be deterministic

Such as

Files found: 0
In my method for the 0 time
In my method for the 1 time
In my method for the 2 time
In my method for the 3 time
...
In my method for the n time
Files found: 128

And for the first few requests it is as expected. Then I get the following for as long as I refresh

Files found: 0
In my method for the 0 time
Files found: 128

Even though I know, from previous refreshes and no code/file alterations that it takes n times to enumerate 128 files.

So the question then: Does mod_wsgi/Python include internal optimizations that would stop complete execution? Does it guess the output is deterministic and cache?

As a note, in the refreshes when it is as expected, REMOTE_PORT increments by one each time … when it uses a short output, the increment of REMOTE_PORT jumps wildly. Might be unrelated however.

I am new to Python, be gentle

Solved

Who knows what it was, but ripping out Apache, mod_python, mod_wsgi and nearly everything HTTP related and re-installing fixed the problem. Something was pretty broken but seems ok now 🙂

  • 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-11T19:25:56+00:00Added an answer on May 11, 2026 at 7:25 pm

    “Does mod_wsgi/Python include internal optimizations that would stop complete execution? Does it guess the output is deterministic and cache?”

    No.

    The problem is (generally) that you have a global variable somewhere in your program that is not getting reset the way you hoped it would.

    Sometimes this can be unintentional, since Python checks local namespace and global namespace for variables.

    You can — inadvertently — have a function that depends on some global variable. I’d bet on this.

    What you’re likely seeing is a number of mod_wsgi daemon processes, each with a global variable problem. The first request for each daemon works. Then your global variable is in a state that prevents work from happening. [File is left open, top-level directory variable got overwritten, who knows?]

    After the first few, all the daemons are stuck in the “other” mode where they report the answer without doing the real work.

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

Sidebar

Ask A Question

Stats

  • Questions 128k
  • Answers 128k
  • 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 Try the blockui plugin May 12, 2026 at 5:37 am
  • Editorial Team
    Editorial Team added an answer var petsXml; var catList = petsXml.*.(@type == "cat"); See "Filters"… May 12, 2026 at 5:37 am
  • Editorial Team
    Editorial Team added an answer The function you're looking for is count_all_results, and you are… May 12, 2026 at 5:37 am

Related Questions

So I have a nasty stack overflow I have been trying to track down
I have an array of 5 items that is also used as the content
I'm trying to track down an issue in our system and the following code
I've been encountering an OverflowException recently within GDI+ via a 3rd party tool which

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.