I put the following in my manage.py (using django-celery 3.0.21):
import eventlet
pymysql = eventlet.import_patched('pymysql')
pymysql.install_as_MySQLdb()
And I get the following error when I try to start django or celery:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
pymysql.install_as_MySQLdb()
File "/home/ubuntu/.virtualenvs/myenv/lib/python2.6/site-packages/pymysql/__init__.py", line 115, in install_as_MySQLdb
sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["pymysql"]
KeyError: 'pymysql'
Basically I really want to use celery with eventlet but I need a "greenable" Python MySQL library for this.
Thank you, that looks like a bug in eventlet.import_patched()
, I've opened an issue [1] in bug tracker.
You can use the following code:
import eventlet
eventlet.monkey_patch()
# everything below is patched to be green
import pymysql
pymysql.install_as_MySQLdb()
[1] Related Eventlet issue https://github.com/eventlet/eventlet/issues/81