At work we're using gevent to create some asynchronous servers, and there's some debate about when to perform monkey patching in relation to other modules. The gevent documentation shows things like this:
from gevent import monkey
monkey.patch_socket()
import socket
Where the monkey patching happens before the library modules have been imported.
However, my manager feels the order of monkey patching should be this:
import socket
from gevent import monkey
monkey.patch_socket()
Where monkey patching is called after the library module is imported. Which makes it look like monkey patching sees the socket module has been imported, and patches it at that point.
I've found some discussions that say do it one way, and others that say to do it the other. My own simple testing seems to say it doesn't matter. Does anyone have an opinion on this, with some clear reasons why, or references that would say why?
Thanks in advance!! Doug