分辨率大于1秒的signal.alarm函数? [英] signal.alarm function with resolution greater than 1 second?

查看:34
本文介绍了分辨率大于1秒的signal.alarm函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个以毫秒为单位运行的 python 超时异常.

I'm trying to build a python timeout exception that runs in milliseconds.

python signal.alarm 函数有 1 秒的分辨率.

The python signal.alarm function has a 1 second resolution.

如何获得以毫秒为单位向给定进程请求 SIGALRM 信号的等效函数,而不是秒?

How would one get an equivalent function that requests a SIGALRM signal to a given process in, say milliseconds, as opposed to seconds?

目前我还没有找到简单的解决方案.

I've found no simple solutions as of yet.

预先感谢您的意见.

推荐答案

使用 signal.setitimer() 代替.

这篇关于分辨率大于1秒的signal.alarm函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆