views:

62

answers:

1

hello all. My main question is does the Threading lock object create atomic locks? It doesn't say that the lock is atomic in the module documentation. in pythons mutex documentation it does say the mutex lock is atomic but it seems that I read somewhere that in fact it isn't. I am wondering if someone could could give me a bit of insight on this mater. Which lock should I use. I am currently running my scripts using python 2.4

+3  A: 

Locks of any nature would be rather useless if they weren't atomic - the whole point of the lock is to allow for higher-level atomic operations.

All of threading's synchronization objects (locks, rlocks, semaphores, boundedsemaphores) utilize atomic instructions, as do mutexes.

You should use threading, since mutex is actually deprecated going forward (and removed in Python 3).

Amber
Thanks, I just wanted to double check.
Richard
And a bigger reason not to use the `mutex` module: its locks are thread-ignorant. They're for use in single-threaded programs using the `sched` module. Essentially, they're useless.
Thomas Wouters
@Thomas Wouters, I take it that's why they are no longer keeping the mutex module in python 3
Richard