title: SQLAlchemy, mysql and concurrent sessions
body: <p>I have multi-thread python3 app. To access database I use SQLAlchemy 1.0.6 (that uses MySQL sessions).</p>
  
  <p>Database has table <code>WorkerTask</code> that contain tasks with different statuses.
  Threads of my app (workers) execute given tasks and change its status during execution: 'pending', 'running', 'finished'.</p>
  
  <p>Another thread (monitor) checks statuses of the tasks and perform some actions.
  At this point I have a bug - monitor request tasks statuses from database, but receives old statuses of tasks. Seems that tasks states do not change since monitor thread launched and its database connection opened.</p>
  
  <p>I checked row response from MySQL - monitor thread receive outdated data.
  At the same time using phpmyadmin I see right statuses of tasks.
  So my workers threads persist changes into database, but monitor receives outdated data.</p>
  
  <p>I think this is an MySQL trick tied with its sessions.</p>
  
  <p>How to fix it?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>Reason of failure and how to fix it described here: <a href="https://stackoverflow.com/questions/31476371/sqlalchemy-entity-not-marked-as-expired">SQLAlchemy - entity not marked as expired</a></p>