python 踏板 - 时间

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 踏板 - 时间相关的知识,希望对你有一定的参考价值。

# delay 6s
import time
time.sleep(4)


# after 30 seconds, "hello, world" will be printed

def hello():
    print "hello, world"

t = Timer(30.0, hello)
t.start()  

# Start a function ina tread;
t =  Thread(target = mail,args=(emailTo ,subject,emailText, filePath))
t.start()


# getting data out of a tread
#https://www.derivative.ca/Forum/viewtopic.php?f=4&t=11395#
from threading import Thread, Lock

TEXT = None
TEXT_LOCK = Lock()

def poll():
    text = None
    with TEXT_LOCK:
        text = TEXT
    if text is not None:
        op('text').text = text
        op('polltimer').par.initialize.pulse()

def network_op():
    Thread(target=network_op_sync).start()

def network_op_sync():
    global TEXT
    resp = requests.post(...)
    if resp.ok:
        with TEXT_LOCK:
            TEXT = resp.text

以上是关于python 踏板 - 时间的主要内容,如果未能解决你的问题,请参考以下文章

Vim Clutch | 面向脚踏板编程

在 Mathematica 和 MIDI 踏板事件中叠加音乐曲目

有料Abaqus/ATOM汽车制动踏板拓扑优化

Vim 离合器,面向脚踏板编程

带有Arduino的Alt-Tab踏板

给FootSwitch脚踏板增加静音开关