[Python-Dev] Re: Thread safety of deques (original) (raw)

Moore, Paul Paul.Moore at atosorigin.com
Tue Jul 20 10:24:03 CEST 2004


From: Aahz

On Mon, Jul 19, 2004, Phillip J. Eby wrote:

However, anything that calls back into Python code isn't necessarily atomic, and in general, almost anything can call back into Python code. Yup.

For example, the seemingly harmless dictionary item assignment can call back into Python for a custom type's hash and eq methods, so could it be that a thread switch could actually occur during this statement:

foo[bar] = baz if 'bar' has such custom methods? Maybe I'm wrong, and the GIL is still held in such a case, but I'm not sure how.

No, it isn't.

Hmm. I think that makes the point fairly well - thread safety is subtle, and not to be taken lightly. Whether that was Raymond's point or mine, I'm less sure :-)

I'll take Raymond's suggestion and see if I can come up with a relatively succinct description of thread safety which would be suitable as a glossary entry.

Paul.


This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.




More information about the Python-Dev mailing list