title: Keep python telegram bot running
body: <p>I made a telegram bot using python and the pyTelegramBotAPI api. The thing is, when I run my bot more than 5 minutes it throws an error "conection reset by peer". So I decided to do an infinite polling. with infinite polling stops working every 10 min for 1 min throwing:</p>
  
  <pre><code>RuntimeError: maximum recursion depth exceeded
  </code></pre>
  
  <p>After that, It runs for 10 min more, but with this error:</p>
  
  <pre><code>    2018-08-01 21:16:27,187 (util.py:65 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response
   body:\n[{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}]',)
  </code></pre>
  
  <p>And If I decide to send something in telegram, sometimes the bot make double response, It seems they are running two instances of the bot, but why?</p>
  
  <p>There is a way to solve this? Maybe a shell scripting to terminate the process using scheduling every n minutes or something like that.</p>
  
  <p>I tried also deploy with heroku with no sucess.</p>
  
  <p>Every idea to keep that bot running is welcome. Here is my polling:</p>
  
  <pre><code>def principal():
      while True:
          try:
              bot.infinity_polling(True)
              bot.polling(none_stop=True)
          except:
              time.sleep(10)
  
  
  principal()
  </code></pre>