def timedwait(self, timeout=0, no_eintr=True):
        """Decrement the value of the semaphore, waiting up to timeout if
        required."""
        timespec = c_struct_timespec()
        self._clock_gettime(0, byref(timespec))
        sec = int(timeout)
        nsec = int((timeout - sec) * 1000000000)
        timespec.tv_sec += sec
        timespec.tv_nsec += nsec
        if timespec.tv_nsec >= 1000000000:
            timespec.tv_sec += 1
            timespec.tv_nsec -= 1000000000
        while True:
            if self._sem_timedwait(self.sem_p, byref(timespec)):
                if self._error().contents.value == ETIMEDOUT:
                    return False
                elif not no_eintr or self._error().contents.value != EINTR:
                    raise SemError()
            else:
                return True
Decrement the value of the semaphore, waiting up to timeout if
        required.
recipes/Python/577655_POSIX_Semaphore_FreeBSD/recipe-577655.py