Re: pyPgSQL, threads and Solaris

Jason Ish <[email protected]> Tue, 31 Aug 2004 01:24:53 -0600
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
> "/export/home/jason/awsrc/scooby/othersrc/fakeroot/lib/python2.3/site-packages/pyPgSQL/PgSQL.py",
> | line 3267, in fetchall
> |     self.res = self.conn.conn.query('FETCH ALL FROM "%s"' % self.name)
> | OperationalError: could not receive data from server: Error 0
> |
> | By using fetchone() I can usually get a few items but end up with a
> | similar traceback.
> |
> | pyPgSQL is built against Python 2.3.4 and PostgreSQL 7.3.4.  I'm not
> | really sure if its a problem in pyPgSQL, libpq or in Python threads
> | support on Solaris but thought I'd start hunting here first.
> |
> | The same code works fine in Linux, FreeBSD and OpenBSD.
> |
> | Any ideas?  I think my next course of action is to try and reproduce a
> | similar failure with C/libpq.
> |
> | Thanks,
> | Jason
> 
> My first guess is that you are using the same connection in multiple
> threads, which is dangerous as connections are not thread safe objects.
> This can cause the symptoms you are seeing.  Make sure that each thread
> has it's own connection object.

I'm opening the database connection in the main thread and getting a
cursor and doing the query in another thread while the first thread is
sleeping.. No other cursors or queries were opened - this is a very
simple test case.

I tried moving the connect() to the thread but it didn't help.  I
still have yet to do my C/libpq test tho.

Thanks,
Jason


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click