title: MSAL for Python. Ocasionally getting error "AADSTS50196: The server terminated an operation because it encountered a client request loop"
body: <p>We have daemon application which reads e-mail from MS365. App reads dozen of mailboxes. Error hapens on very few mailboxes and ocassionally. When second server takes responsibility of mail reading, mails are fetched. If second server fails to fetch mails and first one takes mail reading task, reading mail works. Never able to reproduce.
  Application is multithreaded. Exclusive lock was added to prevent multhithreaded access. Problem occures when token expires and application calls <code>acquire_token_by_username_password </code>. Specified scope is 'Default'. Error message:</p>
  <pre class="lang-json prettyprint-override"><code>{
  'error': 'invalid_grant',
  'error_description': 'AADSTS50196: The server terminated an operation because it encountered a client request loop. Please contact your app vendor'
  }
  </code></pre>
  <p>If grant would be invalid, it should fail always.
  This is long running problem. Customer upgraded MSAL library but it did not help.
  Any suggestion in which direction to go to solve problem?
  UPDATE:
  It is possible to reproduce problem.</p>
  <ol>
  <li>Make loop and call <code>acquire_token_by_username_password</code> inside loop</li>
  <li>Wait up to 10 seconds</li>
  <li>Next loop</li>
  </ol>
  <p>After 20 attempts you will get <code>AADSTS50196</code> error. If you increase wait time to 30 seconds, you can run loop about 35 times. Increasing wait time increases number of requests.<br />
  <strong>But if you recreate PublicClientApplication</strong>, after every wait, no error. You can ran authentication request as many times as you like.<br />
  There is something in request what identifies app.</p>