add global gevent lock for ctx

Whenever a gevent thread needs to modify ctx, it needs to protect the
code with a gevent lock. Add a gevent_lock object which is an instance
of http://gevent.org/gevent.lock.html for this purpose.

Signed-off-by: Loic Dachary <loic@dachary.org>