A. Jesse Jiryu Davis A. Jesse Jiryu Davis - 9 months ago 57
Python Question

How do I detect if Gevent's monkey-patching is active?

I have a Python unittest that depends on

and therefore must not run when Gevent's monkey-patching is active. Is there a Python statement that can tell me whether
has run or not?


I'm not sure there is an idiomatic way, but one simple way would be to check the socket.socket class:

import gevent.monkey, gevent.socket
import socket

if socket.socket is gevent.socket.socket:
    print "gevent monkey patch has occurred"