It's highly advised that monkey-patching be done at the beginning of the main application script, before other imports. Imagine an app or some other imported module that caches something from a module that is patched by gevent monkey - e.g., g_socketClass = socket.socket. So, by the time that your module is imported, it may be too late to patch.
That said, it is often a bad idea to do system-level patch (especially patch_all) in a "library" module. Although easy and it seems to work at first, this system-level patching may conflict with some applications and cause unpredictable, difficult to debug failures. For example, I have reported and seen reports from others about failures when using the pymysql with dbutils shared connection pool in combination with gevent monkey-patching of socket (which is patched by gevent.monkey.patch_all()). If you have to patch at all, I find it better to perform "directed" patching instead: e.g., to make Thrift client gevent-friendly, instead of patching at system level (possibly causing side-effects), I patch only Thrift like this: import TSocket; TSocket.socket = gevent.socket
Cheers