Re: MySQL: Commands out of sync; you can't run this command now

Oleg Broytman <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
Hi!

On Tue, Apr 16, 2013 at 10:52:29AM +0100, "Maciej (Matchek) Blizi??ski" <[email protected]> wrote:
>   File "/opt/csw/lib/python/site-packages/sqlobject/mysql/mysqlconnection.py",
> line 71, in makeConnection
>     conn.ping(True) # Attempt to reconnect. This setting is persistent.
> ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

   conn.ping() is intended to reopen the connection after a timeout;
AFAIR the default timeout is 3600 seconds, not a few minutes. There
shouldn't be any problem with ping after a minute or two.

   "Commands out of sync"means the application calls functions in the
wrong order:
https://dev.mysql.com/doc/refman/5.1/en/commands-out-of-sync.html
   Is the app multithreaded? Could it be the app tries to reuse the same
transaction in different threads?

> Does it look like a problem with my application, or does it look like
> something that should be handled on the SqlObject side? Or should I
> check for the state of the connection at the start of this function?

   None of that, I'm sure. Unfortunately I cannot help further -- I
seldom use MySQL, I use Postgres for bigger projects and SQLite for
smaller ones, so I have to rely on on other people's feedback.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.