synchronized methods or blocks

Gordon McMillan gmcm at hypernet.com
Thu Mar 16 19:14:31 EST 2000


Don <don_b at my-deja.com> writes:

> I am looking for some resources or examples that show how to make
> methods or blocks of code synchronized in Python. I am familiar with
> Java threading and synchronization but not Python.

Then the threading module should be easy for you to learn, 
since it's modelled after Java. There's no synchronized 
keyword, so

  {
    synchronized obj;
    ....
  }

becomes

  rlock.aquire()
  ....
  r.lock.release()

(most probably with a try... finally).

- Gordon




More information about the Python-list mailing list