Exception for errors raised by the Sem class.
| 22 | return func |
| 23 | |
| 24 | class SemError(RuntimeError): |
| 25 | """Exception for errors raised by the Sem class.""" |
| 26 | _error = get_func("libc.so", "__error", POINTER(c_int), ()) |
| 27 | _strerror = get_func("libc.so", "strerror", c_char_p, (c_int,)) |
| 28 | |
| 29 | def __init__(self): |
| 30 | """Create an exception based on the value of errno""" |
| 31 | self.errno = self._error().contents.value |
| 32 | RuntimeError.__init__(self, self.errno, self._strerror(self.errno)) |
| 33 | |
| 34 | class c_struct__usem(Structure): |
| 35 | """FreeBSD provate semaphore structure.""" |