Queue.Queue-like class without the busy-wait

Paul Rubin http
Wed Mar 30 11:14:56 CEST 2005

Antoon Pardon <apardon at forel.vub.ac.be> writes:
> I'm not sure that this would be an acceptable approach. I did the man
> semop and it indicates this is part of system V IPC. This makes me
> fear that semaphores will use file descriptors or other resources
> that are only available in a limited amount. Not usefull if you are
> talking about thousands of threads.

That would be terrible, if semaphores are as heavy as file descriptors.
I'd like to hope the OS's are better designed than that.

So, if we have to do this at user level, the two best choices seem to
be either your pipe method, or an asynchronous sigalarm handler that
goes and releases any timed out locks.  The sigalarm method is
conceptually cleaner, but it involves hacking C code, so it's not so
easy.  Plus I think using sigalarm results in more total system calls
if there's lots of timeouts.  I do believe that the current scheme
with the slow-motion spinlocks is pretty revolting and that any of the
alternatives we've discussed are better.

I wonder what the Pypy folks are doing.  It would be great if they
have some general treatment of asynchronous exceptions.

More information about the Python-list mailing list