Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
mod_wsgi + threading.local: Is it safe?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Frederik Vogelsang  
View profile  
 More options Apr 27 2012, 3:40 pm
From: Frederik Vogelsang <frederik.vogels...@googlemail.com>
Date: Fri, 27 Apr 2012 21:40:09 +0200
Local: Fri, Apr 27 2012 3:40 pm
Subject: mod_wsgi + threading.local: Is it safe?
Hello everyone.

I am working on a Django application which is served through Apache
and mod_wsgi.
We need access to the user object in models (without Django's usual
request.user context). I am planning to use threading.local() for
this. Is there anything to look out for when doing this? Is this even
save? It would be a severe issue if a request's thread-local data
could be destroyed/overwritten by another (maybe parallel) request,
this is why I am asking.

Kind regards,
 Frederik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Garber  
View profile  
 More options Apr 27 2012, 4:03 pm
From: Jason Garber <ja...@gahooa.com>
Date: Fri, 27 Apr 2012 16:03:45 -0400
Local: Fri, Apr 27 2012 4:03 pm
Subject: Re: [modwsgi] mod_wsgi + threading.local: Is it safe?

I have used threading.local as a base class for years in heavy production
use with no problem.  We use it for database connections, etc...  mod_wsgi
will never try to send two requests to the same thread at the same time, so
it is quite safe.

Keep in mind that if you derive a class from threading.local, the __init__
method will be called once per thread.  Just FYI.

Hope this helps.
JG

On Fri, Apr 27, 2012 at 3:40 PM, Frederik Vogelsang <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frederik Vogelsang  
View profile  
 More options Apr 28 2012, 11:43 am
From: Frederik Vogelsang <frederik.vogels...@googlemail.com>
Date: Sat, 28 Apr 2012 17:43:05 +0200
Local: Sat, Apr 28 2012 11:43 am
Subject: Re: [modwsgi] mod_wsgi + threading.local: Is it safe?
Hi,

thanks a lot for the input. It's good to know that this is working out
for you. I also found this statement in the mod_wsgi docs under
"Building A Portable Application":
"Data which needs to exist for the life of the request, would need to
be stored as stack based data, *thread local data*, or cached in the
WSGI application environment."

I guess I'll just use threading.local then to store the request's
authentication information globally.

Regards,
 Frederik

2012/4/27 Jason Garber <ja...@gahooa.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Garber  
View profile  
 More options Apr 28 2012, 5:56 pm
From: Jason Garber <ja...@gahooa.com>
Date: Sat, 28 Apr 2012 17:56:48 -0400
Local: Sat, Apr 28 2012 5:56 pm
Subject: Re: [modwsgi] mod_wsgi + threading.local: Is it safe?

I still use postgres for session data, but suggest you check out
redis.ioas a way of having true global data even with load balancing
or multiple
processes.
On Apr 28, 2012 11:43 AM, "Frederik Vogelsang" <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »