[Zope] - pcgi and multi concurrent access
Service Informatique CHSR
chsrinfo@guetali.fr
Wed, 20 Jan 1999 09:17:46 +0400
>In the future, the application itself will be able to
>handle multiple requests simultaneously. This will be
>especially emportant if there are requests that consume alot
>of application time, like indexing large databases.
i suppose this mean that with this new version of pcgi,
one has to write thread-safe code (although I still have to
lean what thread-safe code is :-)). For example, one wouldn't
write this:
class MyData:
"""give access to my data"""
def __init__(self):
self.curs=db.cursor() # shared data -- bad
def request0(self):
"""list the table0 content"""
self.curs.execute("select * from table0")
return self.curs.fetchall()
def request1(self):
"""list the table1 content"""
self.curs.execute("select * from table1")
return self.curs.fetchall()
bobo_application=MyData()
One would write this instead:
class MyData:
"""give access to my data"""
def request0(self):
"""list the table0 content"""
curs=db.cursor()
curs.execute("select * from table0")
return curs.fetchall()
def request1(self):
"""list the table1 content"""
curs=db.cursor()
curs.execute("select * from table1")
return curs.fetchall()
bobo_application=MyData()
Am i right? (about the fact that one should write thread-safe code
*now* to support the new pcgi way of doing)
Of course, this code is just an example, it is not what i intend to do.
Also, why do i get each answer twice? I suppose
you guy hit the "reply to all" button, which reply both to me and to the
list.
On another list, they hack the messages in such a way that when
you reply to the sender, it gets to the list, not the sender. I don't know
how they do it, but it works. Maybe you could do something similar
for zope@zope.org ?
Regards,
Jephte CLAIN
Service Informatique CHSR