"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
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.
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)
>
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
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
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
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? 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