Forums

python manage.py commands stuck

Starting yesterday, I'm experiencing a troubling issue. Anything I execute in my virtualenv's console from manage.py seems to be stucked and never ends, nor shows any output.

Has anyone faced the same issue? is there something I can do to fix it?

Thanks!

If you interrupt it with a Ctrl+C, what do you see in the traceback? Does that give you any clues as to what it's stuck on?

Yes, I see a statement that can't mean any good at all. This is the troubling part:

mysql_exceptions.OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 4")

And this is the full stacktrace (except the part where it says I interrupted via keyboard)

c^C^C^CTraceback (most recent call last):                                                                                                                  
  File "/home/tafveez/.virtualenvs/classifiedvirtualenv/lib/python3.4/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection       
    self.connect()                                                                                                                                         
  File "/home/tafveez/.virtualenvs/classifiedvirtualenv/lib/python3.4/site-packages/django/db/backends/base/base.py", line 119, in connect                 
    self.connection = self.get_new_connection(conn_params)                                                                                                 
  File "/home/tafveez/.virtualenvs/classifiedvirtualenv/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 276, in get_new_connection     
    conn = Database.connect(**conn_params)                                                                                                                 
  File "/home/tafveez/.virtualenvs/classifiedvirtualenv/lib/python3.4/site-packages/MySQLdb/__init__.py", line 81, in Connect                              
    return Connection(*args, **kwargs)                                                                                                                     
  File "/home/tafveez/.virtualenvs/classifiedvirtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 204, in __init__                         
    super(Connection, self).__init__(*args, **kwargs2)                                                                                                     
_mysql_exceptions.OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 4")

Any ideas?

[edited by admin: formatting]

Try switching to the new way of connecting to the mysql server (change your django settings.py from mysql.server to tafveez.mysql.pythonanywhere-services.com). Both should work but the newer way should give a more stable connection. Let us know if you are still having any issues.