Connection.__del__ Exception: "'NoneType' object has no attribute 'pack'"

794 views
Skip to first unread message

wKovacs64

unread,
May 30, 2014, 1:14:36 PM5/30/14
to pymysq...@googlegroups.com
Hello,

I just attempted to switch from MySQL-python to PyMySQL but I am seeing a lot of exceptions like the following:

Exception AttributeError: "'NoneType' object has no attribute 'pack'" in <bound method Connection.__del__ of <pymysql.connections.Connection object at 0xa81a9aec>> ignored

At first, I suspected it may have something to do with how I'm using the database, but I can't figure out the issue and if I switch back to MySQL-python, it goes away. Has anyone seen this before?

For the record, this is a WSGI application running under mod_wsgi (apache2) using Bottle and SQLAlchemy. My general approach is calling create_engine() in my database class init and then repeat calls to connect() and execute().

Thanks.

Naoki INADA

unread,
Jun 5, 2014, 8:39:49 AM6/5/14
to pymysq...@googlegroups.com
What version of PyMySQL do you use?
Connection.__del__ doesn't use `pack`. Upgrading to 0.6.2 may be solve your problem.

wKovacs64

unread,
Jun 5, 2014, 10:59:24 AM6/5/14
to pymysq...@googlegroups.com
I'm using 0.6.2.

I spoke to someone in #python on freenode and he thought it was related to a Python bug that is resolved in 3.4 (I'm using 2.7) where globals are assigned to None in a random/arbitrary order upon interpreter shutdown. The only global is my wsgi application object, but it doesn't sound like there's a better way to do that so I'm stuck with it. As this exception is only occurring on shutdown, it's not necessarily impacting my application aside from annoying output in the error logs, so it's somewhat ignorable I suppose.

Naoki INADA

unread,
Jun 5, 2014, 11:48:09 AM6/5/14
to pymysq...@googlegroups.com
OK, I see. Thanks for your report.

JR Lizaso

unread,
Jun 27, 2014, 12:05:26 AM6/27/14
to pymysq...@googlegroups.com
This thing issue also happen to me. I resolve it by closing the connection before the application shutdown.
Reply all
Reply to author
Forward
0 new messages