title: Django running on gevent with pymysql: ImportError
body: <p>Im trying to run my Django app on a gunicorn server using gevent. Within my gunicorn.conf, I monkeypatched everything:</p>
  
  <pre><code>def on_starting(server):
      from gevent import monkey
      monkey.patch_socket()
  
  def post_fork(server, worker):
      import pymysql
      pymysql.install_as_MySQLdb()
  </code></pre>
  
  <p>UPDATE: I use Django 1.5 with pymysql 0.5</p>
  
  <p>Now when I run Django I get the following Exception:</p>
  
  <pre><code>ImportError at /
  Exception Value: cannot import name SERVER_STATUS
  Exception Location: /var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/pymysql/connections.py in &lt;module&gt;, line 37
  </code></pre>
  
  <p>This is the traceback:</p>
  
  <pre><code>File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
      92.                     response = middleware_method(request)
  File "/var/www/myproject/myproject/myapp/middleware.py" in process_request
      91.             if not request.session.get('language_code', False):
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in get
    57.         return self._session.get(key, default)
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
    168.                 self._session_cache = self.load()
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
    18.                 expire_date__gt=timezone.now()
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/manager.py" in get
    143.         return self.get_query_set().get(*args, **kwargs)
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/query.py" in get
    382.         num = len(clone)
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
    90.                 self._result_cache = list(self.iterator())
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
    301.         for row in compiler.results_iter():
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
    775.         for rows in self.execute_sql(MULTI):
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
    839.         cursor = self.connection.cursor()
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/backends/__init__.py" in cursor
    324.             cursor = self.make_debug_cursor(self._cursor())
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in _cursor
    405.             self.connection = Database.connect(**kwargs)
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/MySQLdb/__init__.py" in Connect
    80.     from MySQLdb.connections import Connection
  File "/var/www/virtualenvs/myproject/local/lib/python2.7/site-packages/pymysql/connections.py" in &lt;module&gt;
    37. from constants import SERVER_STATUS
  </code></pre>
  
  <p>I dont understand why I'm not able to import SERVER_STATUS here. This file exists and inside "python manage.py shell" I am able to import this file. Ie "from pymysql.constants import SERVER_STATUS" works.</p>
  
  <p>Any advices? I could imagine that this is a really stupid bug...</p>
  
  <p>Thanks in advance!</p>