title: How to build a Python logging function that doesn't repeat the exact same message while polling
body: <p>My script is waiting on a task to complete. While waiting, it polls every 30 seconds and logs a message "Task X is in progress".</p>
  
  <p>Since the script waits for 10 minutes, I get 20 messages with the same content.</p>
  
  <p>To add on top of this, the script polls through several tasks of the same kind, so the log looks like this:</p>
  
  <pre><code>"Task X is in progress"
  "Task Y is in progress"
  "Task Z is in progress"
  "Task X is in progress"
  "Task Y is in progress"
  "Task Z is in progress"
  "Task X is in progress"
  "Task Y is in progress"
  "Task Z is in progress"
  "Task X is complete"
  "Task Y is complete"
  "Task Z is complete"
  </code></pre>
  
  <p>How would I construct a new logging method that can handle such repeating messages and print each message only once.</p>
  
  <p>My solution is in the answers, but if you are familiar with other methods, I'd be happy to learn.</p>