Re: Are Lists thread safe?

2007-03-12 Thread Duncan Booth
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > INPLACE_ADD would call MyList.__iadd__ which you have wrapped. But you > have a race condition between that moment and the following > STORE_ATTR, a context switch may happen in the middle. > > It may not be possible to create an absolutely threa

Re: Are Lists thread safe?

2007-03-09 Thread Gabriel Genellina
En Fri, 09 Mar 2007 16:50:04 -0300, abcd <[EMAIL PROTECTED]> escribió: > I guess this might be overkill then... That depends on your target. For the *current* CPython implementation, yes, because it has an internal lock. But other versions (like Jython or IronPython) may not behave that way.

Re: Are Lists thread safe?

2007-03-09 Thread abcd
On Mar 9, 2:50 pm, "abcd" <[EMAIL PROTECTED]> wrote: > I guess this might be overkill then... > > class MyList(list): > def __init__(self): > self.l = threading.Lock() > > def append(self, val): > try: > self.l.acquire() > list.append(self, val) >

Re: Are Lists thread safe?

2007-03-09 Thread abcd
I guess this might be overkill then... class MyList(list): def __init__(self): self.l = threading.Lock() def append(self, val): try: self.l.acquire() list.append(self, val) finally: if self.l.locked(): self.l.rele

Re: Are Lists thread safe?

2007-03-09 Thread abcd
Thanks for the link. I saw that one in my google search but didn't visit it for some reason. Looks like most operations should be just fine. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Are Lists thread safe?

2007-03-09 Thread Greg Copeland
On Mar 9, 1:03 pm, "abcd" <[EMAIL PROTECTED]> wrote: > Are lists thread safe? Or do I have to use a Lock when modifying the > list (adding, removing, etc)? Can you point me to some documentation > on this? > > thanks Yes there are still some holes which can bi

Re: Are Lists thread safe?

2007-03-09 Thread Larry Bates
abcd wrote: > Are lists thread safe? Or do I have to use a Lock when modifying the > list (adding, removing, etc)? Can you point me to some documentation > on this? > > thanks > You really should at least try Google first: http://effbot.org/pyfaq/what-kinds-of-global-value-m

Are Lists thread safe?

2007-03-09 Thread abcd
Are lists thread safe? Or do I have to use a Lock when modifying the list (adding, removing, etc)? Can you point me to some documentation on this? thanks -- http://mail.python.org/mailman/listinfo/python-list