title: Connection Refused #Work around startup races
body: <p>I have this server, client code in which we run the server as a subprocess in py.test and create a client object and connect it with client.
  But I am getting the <code>Connection Refused</code> error, when I am tracing it to open() function wherein the socket is trying to connect to ip and port.</p>
  <p>There a comment is mentioned that <em>For Connection refused errors, work around startup races.</em></p>
  <p><strong>What are the different ways, I can fix the startup race issue?</strong></p>