timermanager.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:sc-controller 作者: kozec 项目源码 文件源码
def timer(self, name, delay, callback, *data, **kwdata):
        """
        Runs callback after specified number of seconds. Uses
        GLib.timeout_add_seconds with small wrapping to allow named
        timers to be canceled by reset() call
        """
        method = GLib.timeout_add_seconds
        if delay < 1 and delay > 0:
            method = GLib.timeout_add
            delay = delay * 1000.0
        if name is None:
            # No wrapping is needed, call GLib directly
            method(delay, callback, *data, **kwdata)
        else:
            if name in self._timers:
                # Cancel old timer
                GLib.source_remove(self._timers[name])
            # Create new one
            self._timers[name] = method(delay, self._callback, name, callback, *data, **kwdata)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号