inverting threads for gevent compatibility