示例#1
0
 def dump_traceback_later(self, timeout, repeat, w_file, exit):
     space = self.space
     timeout *= 1e6
     try:
         microseconds = ovfcheck_float_to_longlong(timeout)
     except OverflowError:
         raise oefmt(space.w_OverflowError, "timeout value is too large")
     if microseconds <= 0:
         raise oefmt(space.w_ValueError, "timeout must be greater than 0")
     fileno, w_file = self.get_fileno_and_file(w_file)
     self.setup()
     self.check_err(
         cintf.pypy_faulthandler_dump_traceback_later(
             rffi.cast(rffi.LONGLONG, microseconds),
             rffi.cast(rffi.INT, repeat), rffi.cast(rffi.INT, fileno),
             rffi.cast(rffi.INT, exit)))
     self.dump_traceback_later_w_file = w_file
示例#2
0
文件: handler.py 项目: mozillazg/pypy
 def dump_traceback_later(self, timeout, repeat, w_file, exit):
     space = self.space
     timeout *= 1e6
     try:
         microseconds = ovfcheck_float_to_longlong(timeout)
     except OverflowError:
         raise oefmt(space.w_OverflowError, "timeout value is too large")
     if microseconds <= 0:
         raise oefmt(space.w_ValueError, "timeout must be greater than 0")
     fileno, w_file = self.get_fileno_and_file(w_file)
     self.setup()
     self.check_err(cintf.pypy_faulthandler_dump_traceback_later(
         rffi.cast(rffi.LONGLONG, microseconds),
         rffi.cast(rffi.INT, repeat),
         rffi.cast(rffi.INT, fileno),
         rffi.cast(rffi.INT, exit)))
     self.dump_traceback_later_w_file = w_file
示例#3
0
def parse_acquire_args(space, blocking, timeout):
    if not blocking and timeout != -1.0:
        raise oefmt(space.w_ValueError,
                    "can't specify a timeout for a non-blocking call")
    if timeout < 0.0 and timeout != -1.0:
        raise oefmt(space.w_ValueError,
                    "timeout value must be strictly positive")
    if not blocking:
        microseconds = 0
    elif timeout == -1.0:
        microseconds = -1
    else:
        timeout *= 1e6
        try:
            microseconds = ovfcheck_float_to_longlong(timeout)
        except OverflowError:
            raise oefmt(space.w_OverflowError, "timeout value is too large")
    return microseconds
示例#4
0
文件: os_lock.py 项目: mozillazg/pypy
def parse_acquire_args(space, blocking, timeout):
    if not blocking and timeout != -1.0:
        raise oefmt(space.w_ValueError,
                    "can't specify a timeout for a non-blocking call")
    if timeout < 0.0 and timeout != -1.0:
        raise oefmt(space.w_ValueError,
                    "timeout value must be strictly positive")
    if not blocking:
        microseconds = 0
    elif timeout == -1.0:
        microseconds = -1
    else:
        timeout *= 1e6
        try:
            microseconds = ovfcheck_float_to_longlong(timeout)
        except OverflowError:
            raise oefmt(space.w_OverflowError, "timeout value is too large")
    return microseconds
示例#5
0
def timestamp_w(space, w_secs):
    if space.isinstance_w(w_secs, space.w_float):
        secs = space.float_w(w_secs)
        if math.isnan(secs):
            raise oefmt(space.w_ValueError, "timestamp is nan")
        result_float = math.ceil(secs * SECS_TO_NS)
        try:
            return ovfcheck_float_to_longlong(result_float)
        except OverflowError:
            raise oefmt(space.w_OverflowError,
                        "timestamp %R too large to convert to C _PyTime_t",
                        w_secs)
    else:
        try:
            sec = space.bigint_w(w_secs).tolonglong()
            result = sec * r_longlong(SECS_TO_NS)
        except OverflowError:
            raise oefmt(space.w_OverflowError,
                        "timestamp %R too large to convert to C _PyTime_t",
                        w_secs)
        return result