faqts : Computers : Programming : Languages : Python : Common Problems : Threads

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 30 people (67%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

Are dictionary lookups threadsafe?
Can I lookup and retrieve an item in a dictionary while another thread is adding an item?

May 22nd, 2000 05:11
unknown unknown, Thomas Wouters


Python takes great care to make sure all builtin operations are 
threadsafe, and tries to make it as easy as possible to make your own 
extensions threadsafe. As long as you write Python, you're very 
threadsafe, because only one thread can execute Python code. If you 
start writing extentions, in C, or embedding Python in a multi-threaded 
program, things get a little more complicated, though, and you'll have 
to pay attention to where you allow multiple (Python) threads to 
execute.