Re: [Zope] - pcgi and multi concurrent access
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
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.
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 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?
Right.
(about the fact that one should write thread-safe code *now* to support the new pcgi way of doing)
Right.
Of course, this code is just an example, it is not what i intend to do.
Note that the database in Zope 2.0 will make writing thread-safe applications much easier. This is because each application thread will have a separate "connection" to the database and it's own copy of objects. So for example, if the first version of MyData above was changed to use a database object, it would be thread safe (using the database that will be included in Zope 2). Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (540) 371-6909 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (3)
-
Andreas Kostyrka -
Jim Fulton -
Service Informatique CHSR