List Info

Thread: CP/MySQLdb reports "MySQL server has gone away" but it hasn't !




CP/MySQLdb reports "MySQL server has gone away" but it hasn't !
user name
2006-03-28 04:36:03
Hi - Recently i started running my development CP server as
follows ...

nohup nice python cposerver.py  >
/home/rshea/cposerver_print_out.txt &

... in order that it should remain active once i had logged
off.

I now find that when there has been no activity for a while
i get an
error from within CP which originates from MySQLdb - 
'MySQL server has
gone away'.

Now if I log on and run mysql from the prompt i can access
the database
as normal so can anyone explain why i get this message ?

By the way the message will go away if i stop and restart
the server

I know the message is associated with MySQL being out of use
for some
time but what i don't understand is (A) how i can stop it
happening
(basically to tell MySQL "I don't care how long you
have to wait until
you hear from me, keep listening !") and (B) why CP
requires a restart
to acknowledge that MySQL is available.

Any information gratefully received.

thanks

richard.

ps - environment is MySQL 5.x, Gentoo is the OS, CP 2.1.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

CP/MySQLdb reports "MySQL server has gone away" but it hasn't !
user name
2006-03-28 08:39:32
On 3/28/06, northof40 <shearichardgmail.com> wrote:
> I now find that when there has been no activity for a
while i get an
> error from within CP which originates from MySQLdb - 
'MySQL server has
> gone away'.

Well it does look like the MySQL connection needs refreshing
from time
to time because I get something similar.  If I try to use my
web-app
if it has not been accessed for a day or two, I get (last
two lines of
traceback):

  File
"D:\Python24\Lib\site-packages\MySQLdb\connection
s.py", line
33, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (2013, 'Lost connection to MySQL server
during query').

If I then retry it works (without me having to restart
anything).   
I'd say this isn'nt MySQLdb's or CherryPy's fault,
because something
similar happens if I leave the MySQL command prompt client
running and
try to reuse it after a day or two.

So I intend to follow this thread the recent thread
"Running Scheduled
functions in Cherrypy ", and write some kind of
database connection
keepalive function

The  Scheduled functions - thread is
at:http://groups.google.co
m/group/cherrypy-users/browse_thread/thread/8b89e9af50254247
?hl=en

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

CP/MySQLdb reports "MySQL server has gone away" but it hasn't !
user name
2006-03-28 09:45:34
You really should avoid keeping a connection open for that
long, and if
you don't have a lot of db-interactions it's better to
close it and get
a new one for every operation.  But an even better solution
is keeping
a connection pool, and for every db-operation (every
transaction, at
least) get a connection from the pool and return it, then
make sure the
connection pool gets rid of connections which have expired.
The expiry
time can be found in the mysql-config.

An example pool can be found here:

http:/subpar.se/pool.py


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

CP/MySQLdb reports "MySQL server has gone away" but it hasn't !
user name
2006-03-28 14:18:33
> An example pool can be found here:
> http:/subpar.se/pool.py

This is not how a 'pool' works.

This code merely instantiates a bunch of objects then it
uses them up
one by one (the get method removes  from the queue), after
that it
alwas creates a new instance.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

CP/MySQLdb reports "MySQL server has gone away" but it hasn't !
user name
2006-03-30 15:29:34
I just migrated from MySQL 4.x to MySQL 5.0.18 and I started getting this odd behavior, which I'll refer to as a bug.

I'm using cherrypy 2.2 with SQLObject , and I use the connectionhub to provide each server thread with its own
connection (i had 5 threads running), it didn't take more than 15 minutes before I got that exception.

I don't know who to blame for this bug. I've temporarily switched to sqlite since my server isn't under a heavy load
but still I would like to use MySQL because it supports concurrent connections.

d

On 3/27/06, northof40 <gmail.com"> shearichardgmail.com> wrote:

Hi - Recently i started running my development CP server as follows ...

nohup nice python cposerver.py &nbsp;> /home/rshea/cposerver_print_out.txt &

... in order that it should remain active once i had logged off.

I now find that when there has been no activity for a while i get an
error from within CP which originates from MySQLdb - &nbsp;'MySQL server has
gone away'.

Now if I log on and run mysql from the prompt i can access the database
as normal so can anyone explain why i get this message ?

By the way the message will go away if i stop and restart the server

I know the message is associated with MySQL being out of use for some
time but what i don't understand is (A) how i can stop it happening
(basically to tell MySQL "I don't care how long you have to wait until
you hear from me, keep listening !") and (B) why CP requires a restart
to acknowledge that MySQL is available.

Any information gratefully received.

thanks

richard.

ps - environment is MySQL 5.x, Gentoo is the OS, CP 2.1.1






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users&quot; group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )