Views Counter made in Python, Gevent and MongoDB
Instead of using a list comprehension, I would simply use a for-loop. It will do the exact same thing and save having to allocate a temporary list.

Also, in run_buffer_op, you first check the number of views. If that value isn't &gt;5000 (almost a DBZ joke) then you sleep for 15min. Once it wakes up, you IMMEDIATELY flush_to_db no matter what. Based on your comments,  it seems you only want to flush_to_db if there are &gt;5000 views. Thus, the flush_to_db call immediately after the gevent.sleep(900) seems a little redundant.