Probably not related to your issue, but wouldn't you want to leave the
connection (or connection pool) open between transactions, and just
create/destroy cursors in the awake/sleep cycle?
-Jacob
On Wed, 23 Feb 2005 23:15:43 -0800, jose <jose@...> wrote:
> Dear webware community,
>=20
> I'm perplexed, I have been playing around with XMLRPC as a way to connect=
to
> a database and deliver content. Please see the code below:(one is a
> XMLRPCServlet and the second is a regular servlet)
>=20
> The is issue is that the XMLRPC servlet is about 8 times slower then the
> regular servlet. This doesn't make any sense to me. If I kill the sleep
> method, and not close the db connection, then it is really fast, but some=
how
> that does not feel right. I don't seem to be taking much of a hit by
> getting a new connection every time with the regular servlet, so why shou=
ld
> it be so with the xmlrpc servlet? Am I doing something fundamentally wron=
g
> in the xmlrpc?
>=20
> Any help would be great, and thanks in advance
>=20
> Jose
>=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> server.py:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> from WebKit.XMLRPCServlet import XMLRPCServlet as XS
> import psycopg as pg
>=20
> class server(XS):
>=20
> def __init__(self):
> XS.__init__(self)
> self.db =3D None
>=20
> def awake(self, trans):
> XS.awake(self, trans)
> self.db =3D pg.connect(user =3D 'postgres', database=3D'phonebook'=
)
> def sleep(self, trans):
> XS.sleep(self, trans)
> if self.db:
> self.db.close()
> def cur(self):
> return self.db.cursor()
>=20
> def exposedMethods(self):
> return [
> 'echo',
> 'listPeople'
> ]
>=20
> def echo(self, what=3D'you need to enter something'):
> return what
>=20
> def listPeople(self):
> sql =3D '''
> select
> fname,
> lname
> from people
> '''
> cur =3D self.cur()
> cur.execute(sql)
> people =3D cur.fetchall()
> return people
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> test.py
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> from WebKit.Page import Page
> import psycopg as pg
>=20
> class test(Page):
>=20
> def __init__(self):
> Page.__init__(self)
> self.db =3D None
>=20
> def awake(self, trans):
> Page.awake(self, trans)
> self.db =3D pg.connect(user =3D 'postgres', database=3D'phonebook'=
)
>=20
> def sleep(self, trans):
> Page.sleep(self, trans)
> if self.db:
> self.db.close()
> def cur(self):
> return self.db.cursor()
>=20
> def writeContent(self):
> sql =3D '''
> select
> fname,
> lname
> from people
> '''
> cur =3D self.cur()
> cur.execute(sql)
> people =3D cur.dictfetchall()
> self.write(people)
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
> =3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_ide95&alloc_id=14396&opclick
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@...
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
>
|