On 06-10-2008, gert wrote:
>
> On Oct 6, 11:48 pm, gert <[EMAIL PROTECTED]> wrote:
>> Will this share connections between requests ?
>>
>> import _mysql
>> db = _mysql.connect('127.0.0.1','root','root','www')
>>
>> def application(environ, start_response):
>>     db.query("SELECT test FROM test")
>>     row = db.store_result()
>>     v = row.fetch_row()[0][0]
>>     db.close()
>>     response_headers = [('Content-type', 'text/html'),('Content-
>> Length', str(len(v)))]
>>     start_response('200 OK', response_headers)
>>     return [v]
>
> nope it gives the exact same result, works one time and after the
> first request you get
> [Tue Oct 07 00:54:22 2008] [error] [client 80.200.212.91] Traceback
> (most recent call last):, referer: http://87.98.218.86/
> [Tue Oct 07 00:54:22 2008] [error] [client 80.200.212.91]   File "/srv/
> www/gil.py", line 12, in application, referer: http://87.98.218.86/
> [Tue Oct 07 00:54:22 2008] [error] [client 80.200.212.91]
> db.query("SELECT test FROM test"), referer: http://87.98.218.86/
> [Tue Oct 07 00:54:22 2008] [error] [client 80.200.212.91]
> InterfaceError: (0, ''), referer: http://87.98.218.86/
>
> so can you  make modwsgi share global variables between requests ?

It is. In your example db will be shared between requests.

But if you have more than one thread you have to know how to share 
theses resources ! Is your connection thread safe ?
Don't forget also that if you share the same db connection between 
request you cannot use transaction...

You use _mysql instead of mysql and a query on the connection instead of 
the cursor...  I don't know what you do !

-- 
William Dodé - http://flibuste.net
Informaticien Indépendant


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to