title: Python multithreading
body: <p>I have this scenario:</p>
  
  <p>A web page created with Zope/Plone and some mine python API. There's a web page, call it "a", that by a python method calls a database (Postgres) and returns some information. On page "a" you can modify database data "offline" (I intend that the changes aren't written in the database instantly but in a second moment when you press "save" and call a python API method). So, imagine this scenario: an user, called "Sam", loads the page and start to modify data. Meanwhile an user, called "Sara", modifies the database by the page "a" clicking "save".  Now Sam doesn't have the actual database data: he'll push "save" and overwrite Sara's data change.</p>
  
  <p>I would have an alert on my page in real time. I thought I can do something like this:</p>
  
  <p>Make an AJAX call, that isn't blockable, and keep going with page render. The AJAX calls a python method that creates a thread that does an infinite loop (on an "X" condition). When I write data on database, I'll call a function that will change "X condition" stopping the thread and returning to AJAX.</p>
  
  <p>Moreover, I can't lock the database because I have to give free access to every user that wants to modify my database.</p>
  
  <p>My problem is: how can I identify a python thread ? I've just saw that every single method on a class that inherit from Thread wants "self" as parameter. Moreover, I have to call the thread as I access the "a" page and this will be somewhere in the code (say on the "threads module") but the inserts are on the other module. So, how can I realize my idea ?</p>
  
  <p>And if someone have an alternative idea, tell me without any problem :)</p>