Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python在满足高精度条件后无阻塞延迟_Python_Delay_Python Multithreading_Blocking - Fatal编程技术网

python在满足高精度条件后无阻塞延迟

python在满足高精度条件后无阻塞延迟,python,delay,python-multithreading,blocking,Python,Delay,Python Multithreading,Blocking,我需要在满足条件后在python中执行一个函数,但是在执行该函数之前有一个轻微的秒延迟,而不会阻塞循环中的另一个程序,并且延迟必须是高精度的 有办法吗?我试过使用threading.Thread和threading.Timer但是延迟不是那么精确。这是我的密码: count = 2500 delay = 0.5 # delay before executing function while True: # Another program here ....... if(c

我需要在满足条件后在python中执行一个函数,但是在执行该函数之前有一个轻微的秒延迟,而不会阻塞循环中的另一个程序,并且延迟必须是高精度的

有办法吗?我试过使用
threading.Thread
threading.Timer
但是延迟不是那么精确。这是我的密码:

count = 2500
delay = 0.5 # delay before executing function
while True:
    # Another program here
    .......
    if(count <= 2000):
        if(found == 0): # Run once until count >= 2000 again
            # Execute pressKey function
            startThread = threading.Timer(delay, pressKey).start()
        found = 1

    if(count >= 2000):
        if(found == 1): # Run once until count <= 2000 again
            # Execute releaseKey function
            endThread = threading.Timer(delay, releaseKey).start()
        found = 0
count=2500
延迟=0.5#执行功能前的延迟
尽管如此:
#这里还有一个节目
.......
如果(再次计数=2000
#执行按键功能
startThread=threading.Timer(延迟,按键).start()
发现=1
如果(计数>=2000):

如果(找到==1):#运行一次,直到计数。您只能同时运行一个进程。共享对象应存储在标志和值中的全局变量中。创建稳定或加快进程的第一个阶段,您必须选择。每个状态标志处理器时间中的一个部分必须通过扫描。板条应用程序同步很困难。任何内容都不可更改未编写原型的itten应用程序。根据原型的实际实现值,原型仅限于事务。这是一个复杂的情况,取决于您的系统和硬件速度/能力。@dsgdfg很抱歉,我有点难以理解您对标志、处理器、板条应用程序同步的评论,但是您的意思是哪个进程同时只能运行一个?它是
线程。计时器
?全局标志用于具有数据关系的子进程中。例如run_sub_thread(my_Global_var_1,…),run_sub_thread1(my_Global_var_1,…),您不能更改my_Global_var_1变量(在子进程中)。管理员、从业者、控制器、安全性是应用程序不可或缺的组成部分。您可以在计算机上一次执行一个操作(对于程序员)。您可以启动不同的进程,但实际上这意味着运行单个事务,因为过滤器将前进到特定的步骤。Chronos拥有所有控件。