On Oct 7, 9:58 am, William Dode <[EMAIL PROTECTED]> wrote:
> 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 !
_mysql is a 50% speed increase on what Graham calls the "not again"
benchmark script made by me with has a soul purpose to get the number
of request as high as possible ignoring things like security,
reliability, memory, processing you know the benchmark everybody is
interested in :-)
So clearly my db connections are not made to be used globally and as
always before Graham can say "for god sake why me" i blame Graham for
it.
Your are ride about the START TRANSACTION; not going to work like that
but never the less, I still expect the simple query thing to work and
share the database connection. Note that i use prefork not worker
apache (prefork faster btw using mod_wsgi) So its just memory from a
single process that needs to be available to a other request handled
by the same single threaded process. Unless there is a line in
mode_wsgi that say's if ( group == gert ) { malloc(size_t
i_dont_think_so); } I still think it should work ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---