This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients belopolsky, brett.cannon, christian.heimes, grahamd, gvanrossum, ncoghlan, neologix, pitrou, vstinner
Date 2011-12-30.10:55:57
SpamBayes Score 3.9361e-08
Marked as misclassified No
Message-id <>
In-reply-to <1325173722.3325.4.camel@localhost.localdomain>
> That's true. Do you think temptatively acquiring the lock (without
> blocking) would solve the issue?

I think it should work. Something along those lines:

while True:
    if lock.acquire(0):
        lock.tstate = tstate
        return True
        if detect_circularity():
            return False
        saved = save_tstate()

However, I find this whole mechanism somewhat complicated, so the
question really is: what are we trying to solve?
If we just wan't to avoid deadlocks, a trylock with the global import
lock will do the trick.
If, on the other hand, we really want to reduce the number of cases
where a deadlock would occur by increasing the locking granularity,
then it's the way to go. But I'm not sure it's worth the extra
complexity (increasing the locking granularity is usually a proven
recipe to introduce deadlocks).

> Isn't this limit only about named semaphores? Or does it apply to
> anonymous semaphores as well?

I'm no FreeBSD expert, but AFAICT, POSIX SEM_NSEMS_MAX limit doesn't
seem to make a distinction between named and anonymous semaphores.
From POSIX sem_init() man page:
A resource required to initialise the semaphore has been exhausted, or
the limit on semaphores (SEM_NSEMS_MAX) has been reached.

Also, a quick search returned those links:,v
So it seems that sem_init() can fail when the max number of semaphores
is reached.
Date User Action Args
2011-12-30 10:55:59neologixsetrecipients: + neologix, gvanrossum, brett.cannon, ncoghlan, belopolsky, pitrou, vstinner, christian.heimes, grahamd
2011-12-30 10:55:58neologixlinkissue9260 messages
2011-12-30 10:55:57neologixcreate