[Python-3000] threading, part 2

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Aug 8 21:05:24 CEST 2006


"tomer filiba" <tomerfiliba at gmail.com> writes:

> after all, exceptions can occur anywhere in the code, and at any time...

It's impossible to write safe code when exceptions can occur at any
time, except when you already happen have the needed atomic primitives
available.

Let's say we have a mutable doubly linked list (the list have first
and last pointers, each node has next and prev pointers). Please show
how to append a first node if exceptions can occur at any time. Not
adding the element at all if an asynchronous exception is coming is
acceptable, but corrupting the list structure is not.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


More information about the Python-3000 mailing list