I am using PyMongo and gevent together, from a Django application. In production, it is hosted on Gunicorn.
I am creating a single Connection object at startup of my application. I have some background task running continuously and performing a database operation every few seconds.
The application also serves HTTP requests as any Django app.
The problem I have is the following. It only happens in production, I have not been able to reproduce it on my dev environment. When I let the application idle for a little while (although the background task is still running), on the first HTTP request (actually the first few), the first "find" operation I perform never completes. The greenlet actually never resumes. This causes the first few HTTP requests to time-out.
How can I fix that? Is that a bug in gevent and/or PyMongo?