コード例 #1
0
ファイル: dsasyncore.py プロジェクト: paul-axe/darknet
def loop(timeout=0.1, returnLiveSockets=False):
    global __somethingHappened
    global __returnLiveSockets
    global __liveSockets

    __somethingHappened = False
    __returnLiveSockets = returnLiveSockets
    __liveSockets = []

    now = dstime.time()
    while not __deferredCallablesQueue.empty():
        origValue = __deferredCallablesQueue.get()
        wakeupTime, callable = origValue
        if now >= wakeupTime:
            callable()
        else:
            __deferredCallablesQueue.put(origValue)
            break

    asyncore.poll(timeout=timeout)
    if __returnLiveSockets:
        return __liveSockets
    else:
        return __somethingHappened
コード例 #2
0
ファイル: dsasyncore.py プロジェクト: paul-axe/darknet
def callLater(callable, delay):
    __deferredCallablesQueue.put((dstime.time() + delay, callable))