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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:15:38+00:00 2026-05-13T10:15:38+00:00

I noticed a strange behaviour today: It seems that, in the following example, the

  • 0

I noticed a strange behaviour today: It seems that, in the following example, the config.CLIENT variable stays persistent accross requests – even if the view gets passed an entirely different client_key, the query that gets the client is only executed once (per many requests), and then the config.CLIENT variable stays assigned.

It does not seem to be a database caching issue.

It happens with mod_python as well as with the test server (the variable is reassigned when the test server is restarted).

What am I missing here?

#views.py
from my_app import config

def get_client(client_key=None):
    if config.CLIENT == None:
        config.CLIENT = get_object_or_404(Client, key__exact=client_key, is_active__exact=True)
    return config.CLIENT

def some_view(request, client_key):
    client = get_client(client_key)
    ...
    return some_response

# config.py
CLIENT = None
  • 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-13T10:15:38+00:00Added an answer on May 13, 2026 at 10:15 am

    Multiple requests are processed by the same process and global variables like your CLIENT live as long, as process does. You shouldn’t rely on global variables, when processing requests – use either local ones, when you need to keep a variable for the time of building response or put data into the database, when something must persist across multiple requests.

    If you need to keep some value through the request you can either add it to thread locals (here you should some examples, that adds user info to locals) or simply pass it as a variable into other functions.

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

Sidebar

Related Questions

I have noticed that there are strange requests to my website trying to find
Just today I noticed a strange behavior in an object model that was previously
I've noticed some very strange behaviour today in Code Igniter. I have this locations
I noticed a strange behaviour in my Import Service today when I tried to
When doing some web maintenance today, I noticed a strange new folder on my
Noticed this today when a patch was submitted with the following line: lblCompletionTime.Text =
I was working on a simple script today when I noticed a strange quirk
I just noticed a strange behavior which looks like a bug. Consider the following
I've noticed some strange behaviour in JS window.location.hash = ''; var hash = window.location.hash;
I have noticed a strange behaviour when intercepting the preUpdate row hook in Propel

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.