title: gevent monkey patching order
body: <p>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:</p>
  <pre><code>from gevent import monkey
  monkey.patch_socket()
  import socket
  </code></pre>
  <p>Where the monkey patching happens before the library modules have been imported.</p>
  <p>However, my manager feels the order of monkey patching should be this:</p>
  <pre><code>import socket
  from gevent import monkey
  monkey.patch_socket()
  </code></pre>
  <p>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.</p>
  <p>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. I am seeking opinions on this, with some clear reasons why, or references that would say why.</p>