title: How can uwsgi re-establish connection to remote mysql database whenever mysql services are restarted
body: <p>I have a python web application, where in, the application connects to a remote database.</p>
  
  <p>Application: flask+uwsgi+nginx . </p>
  
  <p>Database :mysql (remote).
  The application exposes rest api for which data is served from remote database.</p>
  
  <p>Everyday after db restoration, mysql service is restarted in the remote database. The connection between my application and remote database breaks, and it starts throwing error message</p>
  
  <pre><code>MySQL server has gone away.
  </code></pre>
  
  <p>until I manually restart the uwsgi service in my application</p>
  
  <pre><code>sudo service uwsgi restart  
  </code></pre>
  
  <p>The duration between mysql service restart in remote db and uwsgi service restart in my system is the <strong>downtime</strong>. </p>
  
  <p>Can my application re establish connection as soon as the mysql services are restarted ?</p>
  
  <p>Please suggest any solutions?</p>