[Python-3000] python-safethread project status

Marcin ‘Qrczak’ Kowalczyk qrczak at knm.org.pl
Tue Mar 18 21:04:12 CET 2008


Dnia 18-03-2008, Wt o godzinie 13:37 -0600, Adam Olsen pisze:

> What sort of blocking wait do you use?  Or did you mean you don't have one?

I meant that I don't have one, I only have iteration over the whole
queue, which is equivalent to having trypop. Which prompts the question:
what are use cases of pop & wait, i.e. of blocking until the queue is
not empty?

I used to have weakref callbacks. They must be synchronized with the
rest of the program (unless their operations on shared data are already
atomic). Then I realized that a design with deathqueues suffices for
cases like WeakKeyDictionary, and it is not less convenient because
the queue can be checked in exactly those places where the design with
callbacks would lock the shared data.

Regarding interrupts, I have a more involved scheme with threads
blocking and unblocking interrupts, with a counter of the number of
blocks, with a special synchronous mode for being interruptible at
blocking operations only (similar to PTHREAD_CANCEL_DEFERRED, but the
default is PTHREAD_CANCEL_ASYNCHRONOUS), and with signals which don't
necessarily cause an exception but they execute a signal handler which
often throws an exception.

I've seen a simpler interrupt blocking scheme being proposed for Python,
based on the design in Haskell:
   http://www.cs.williams.edu/~freund/papers/python.pdf
but it seems to have been abandoned (the paper is from 2002 and I
haven't heard of anything newer).

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



More information about the Python-3000 mailing list