[Zope] - pcgi and multi concurrent access
Andreas Kostyrka
andreas@mtg.co.at
Wed, 20 Jan 1999 16:16:03 +0100 (CET)
On Wed, 20 Jan 1999, Service Informatique CHSR wrote:
> >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
Thread-safe code is code, that for example does:
-) protect shared data by locks. (or other communication methods)
-) have means of avoiding/detecting deadlocks, etc.
> 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)
Not really. If you are using Bobo (not Zope), than it's enough not to use
the new multithreaded model. :)
> 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.
Probably. That's just normal list behaviour.
>
> 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 ?
Not a good idea. Sometimes I rather want to reply to the person.
Additionally, the double message allows for faster discussions: People
activly discussing are getting the mails directly of their thread, which
is faster than via the mailing list. (Actually for Zope it probably
matters less, but more heavy lists can be slow to resend mail :( )
Andreas
--
Win95: n., A huge annoying boot virus that causes random spontaneous system
crashes, usually just before saving a massive project. Easily cured by
UNIX. See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.