python类PumpWaitingMessages()的实例源码

testGIT.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test(fn):
    print "The main thread is %d" % (win32api.GetCurrentThreadId())
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)

    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT
testADOEvents.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def TestConnection(dbname):
    # Create the ADO connection object, and link the event
    # handlers into it
    c = DispatchWithEvents("ADODB.Connection", ADOEvents)

    # Initiate the asynchronous open
    dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=%s" % dbname
    user = "system"
    pw = "manager"
    c.Open(dsn, user, pw, constants.adAsyncConnect)

    # Sit in a loop, until our event handler (above) sets the
    # "finished" flag or we time out.
    end_time = time.clock() + 10
    while time.clock() < end_time:
        # Pump messages so that COM gets a look in
        pythoncom.PumpWaitingMessages()
    if not finished:
        print "XXX - Failed to connect!"
testMSOfficeEvents.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break
        try:
            if not ob.Visible:
                # Gone invisible - we need to pretend we timed
                # out, so the app is quit.
                return 0
        except pythoncom.com_error:
            # Excel is busy (eg, editing the cell) - ignore
            pass
        if time.time() > end:
            return 0
    return 1
eventsApartmentThreaded.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages()
testGIT.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test(fn):
    print "The main thread is %d" % (win32api.GetCurrentThreadId())
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)

    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT
testADOEvents.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def TestConnection(dbname):
    # Create the ADO connection object, and link the event
    # handlers into it
    c = DispatchWithEvents("ADODB.Connection", ADOEvents)

    # Initiate the asynchronous open
    dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=%s" % dbname
    user = "system"
    pw = "manager"
    c.Open(dsn, user, pw, constants.adAsyncConnect)

    # Sit in a loop, until our event handler (above) sets the
    # "finished" flag or we time out.
    end_time = time.clock() + 10
    while time.clock() < end_time:
        # Pump messages so that COM gets a look in
        pythoncom.PumpWaitingMessages()
    if not finished:
        print "XXX - Failed to connect!"
testMSOfficeEvents.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break
        try:
            if not ob.Visible:
                # Gone invisible - we need to pretend we timed
                # out, so the app is quit.
                return 0
        except pythoncom.com_error:
            # Excel is busy (eg, editing the cell) - ignore
            pass
        if time.time() > end:
            return 0
    return 1
eventsApartmentThreaded.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages()
testGIT.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test(fn):
    print "The main thread is %d" % (win32api.GetCurrentThreadId())
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)

    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT
testADOEvents.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def TestConnection(dbname):
    # Create the ADO connection object, and link the event
    # handlers into it
    c = DispatchWithEvents("ADODB.Connection", ADOEvents)

    # Initiate the asynchronous open
    dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=%s" % dbname
    user = "system"
    pw = "manager"
    c.Open(dsn, user, pw, constants.adAsyncConnect)

    # Sit in a loop, until our event handler (above) sets the
    # "finished" flag or we time out.
    end_time = time.clock() + 10
    while time.clock() < end_time:
        # Pump messages so that COM gets a look in
        pythoncom.PumpWaitingMessages()
    if not finished:
        print "XXX - Failed to connect!"
testMSOfficeEvents.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break
        try:
            if not ob.Visible:
                # Gone invisible - we need to pretend we timed
                # out, so the app is quit.
                return 0
        except pythoncom.com_error:
            # Excel is busy (eg, editing the cell) - ignore
            pass
        if time.time() > end:
            return 0
    return 1
eventsApartmentThreaded.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages()
testGIT.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test(fn):
    print("The main thread is %d" % (win32api.GetCurrentThreadId()))
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)

    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print("Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT
testADOEvents.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def TestConnection(dbname):
    # Create the ADO connection object, and link the event
    # handlers into it
    c = DispatchWithEvents("ADODB.Connection", ADOEvents)

    # Initiate the asynchronous open
    dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=%s" % dbname
    user = "system"
    pw = "manager"
    c.Open(dsn, user, pw, constants.adAsyncConnect)

    # Sit in a loop, until our event handler (above) sets the
    # "finished" flag or we time out.
    end_time = time.clock() + 10
    while time.clock() < end_time:
        # Pump messages so that COM gets a look in
        pythoncom.PumpWaitingMessages()
    if not finished:
        print("XXX - Failed to connect!")
testMSOfficeEvents.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break
        try:
            if not ob.Visible:
                # Gone invisible - we need to pretend we timed
                # out, so the app is quit.
                return 0
        except pythoncom.com_error:
            # Excel is busy (eg, editing the cell) - ignore
            pass
        if time.time() > end:
            return 0
    return 1
eventsApartmentThreaded.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages()
trade_ebest.py 文件源码 项目:stock_trade 作者: yoonsungkim87 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def login_process(demo = False):
    if demo:
        server_addr = "demo.ebestsec.co.kr"
        user_certificate_pass = None
    else:
        server_addr = "hts.ebestsec.co.kr"
        user_certificate_pass = ""

    server_port = 20001
    server_type = 0
    user_id = ""
    user_pass = ""

    inXASession = win32com.client.DispatchWithEvents("XA_Session.XASession", XASessionEvents)
    inXASession.ConnectServer(server_addr, server_port)
    inXASession.Login(user_id, user_pass, user_certificate_pass, server_type, 0)

    while XASessionEvents.logInState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()
trade_ebest.py 文件源码 项目:stock_trade 作者: yoonsungkim87 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_top_trade_cost(field = 1, day = 0):
    time.sleep(1)
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t1463.res")
    inXAQuery.SetFieldData('t1463InBlock', 'gubun', 0, field)
    inXAQuery.SetFieldData('t1463InBlock', 'jnilgubun', 0, day)
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    nCount =inXAQuery.GetBlockCount('t1463OutBlock1')
    result = []
    for i in range(nCount):
        result.append(inXAQuery.GetFieldData('t1463OutBlock1', 'shcode', i))
    XAQueryEvents.queryState = 0
    return result
trade_ebest.py 文件源码 项目:stock_trade 作者: yoonsungkim87 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_top_trade_volume(field = 1, day = 0):
    time.sleep(1)
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t1452.res")
    inXAQuery.SetFieldData('t1452InBlock', 'gubun', 0, field)
    inXAQuery.SetFieldData('t1452InBlock', 'jnilgubun', 0, day)
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    nCount =inXAQuery.GetBlockCount('t1452OutBlock1')
    result = []
    for i in range(nCount):
        result.append(inXAQuery.GetFieldData('t1452OutBlock1', 'shcode', i))
    XAQueryEvents.queryState = 0
    return result
winspeech.py 文件源码 项目:winspeech 作者: areebbeigh 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _ensure_event_thread():
    """
    Make sure the event thread is running, which checks the handlerqueue
    for new event handlers to create, and runs the message pump.
    """
    global _event_thread
    if not _event_thread:
        def loop():
            while _event_thread:
                pythoncom.PumpWaitingMessages()
                if _handlerqueue:
                    (context, listener, callback) = _handlerqueue.pop()
                    # Just creating a _ListenerCallback object makes events
                    # fire till listener loses reference to its grammar object
                    _ListenerCallback(context, listener, callback)
                time.sleep(.5)

        _event_thread = 1  # so loop doesn't terminate immediately
        _event_thread = _thread.start_new_thread(loop, ())
testMarshal.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _DoTestMarshal(self, fn, bCoWait = 0):
        #print "The main thread is %d" % (win32api.GetCurrentThreadId())
        threads, events = fn(2)
        numFinished = 0
        while 1:
            try:
                if bCoWait:
                    rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
                else:
                    # Specifying "bWaitAll" here will wait for messages *and* all events
                    # (which is pretty useless)
                    rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
                if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                    numFinished = numFinished + 1
                    if numFinished >= len(events):
                        break
                elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                    # This is critical - whole apartment model demo will hang.
                    pythoncom.PumpWaitingMessages()
                else: # Timeout
                    print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
            except KeyboardInterrupt:
                break
        for t in threads:
            t.join(2)
            self.failIf(t.isAlive(), "thread failed to stop!?")
        threads = None # threads hold references to args
        # Seems to be a leak here I can't locate :(
        #self.failUnlessEqual(pythoncom._GetInterfaceCount(), 0)
        #self.failUnlessEqual(pythoncom._GetGatewayCount(), 0)
testMarshal.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _DoTestMarshal(self, fn, bCoWait = 0):
        #print "The main thread is %d" % (win32api.GetCurrentThreadId())
        threads, events = fn(2)
        numFinished = 0
        while 1:
            try:
                if bCoWait:
                    rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
                else:
                    # Specifying "bWaitAll" here will wait for messages *and* all events
                    # (which is pretty useless)
                    rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
                if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                    numFinished = numFinished + 1
                    if numFinished >= len(events):
                        break
                elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                    # This is critical - whole apartment model demo will hang.
                    pythoncom.PumpWaitingMessages()
                else: # Timeout
                    print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
            except KeyboardInterrupt:
                break
        for t in threads:
            t.join(2)
            self.failIf(t.isAlive(), "thread failed to stop!?")
        threads = None # threads hold references to args
        # Seems to be a leak here I can't locate :(
        #self.failUnlessEqual(pythoncom._GetInterfaceCount(), 0)
        #self.failUnlessEqual(pythoncom._GetGatewayCount(), 0)
testMarshal.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _DoTestMarshal(self, fn, bCoWait = 0):
        #print "The main thread is %d" % (win32api.GetCurrentThreadId())
        threads, events = fn(2)
        numFinished = 0
        while 1:
            try:
                if bCoWait:
                    rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
                else:
                    # Specifying "bWaitAll" here will wait for messages *and* all events
                    # (which is pretty useless)
                    rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
                if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                    numFinished = numFinished + 1
                    if numFinished >= len(events):
                        break
                elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                    # This is critical - whole apartment model demo will hang.
                    pythoncom.PumpWaitingMessages()
                else: # Timeout
                    print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
            except KeyboardInterrupt:
                break
        for t in threads:
            t.join(2)
            self.failIf(t.isAlive(), "thread failed to stop!?")
        threads = None # threads hold references to args
        # Seems to be a leak here I can't locate :(
        #self.failUnlessEqual(pythoncom._GetInterfaceCount(), 0)
        #self.failUnlessEqual(pythoncom._GetGatewayCount(), 0)
sapi5.py 文件源码 项目:pyttsx3 作者: nateshmbhat 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def startLoop(self):
        first = True
        self._looping = True
        while self._looping:
            if first:
                self._proxy.setBusy(False)
                first = False
            pythoncom.PumpWaitingMessages()
            time.sleep(0.05)
sapi5.py 文件源码 项目:pyttsx3 作者: nateshmbhat 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def iterate(self):
        self._proxy.setBusy(False)
        while 1:
            pythoncom.PumpWaitingMessages()
            yield
testMarshal.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _DoTestMarshal(self, fn, bCoWait = 0):
        #print "The main thread is %d" % (win32api.GetCurrentThreadId())
        threads, events = fn(2)
        numFinished = 0
        while 1:
            try:
                if bCoWait:
                    rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
                else:
                    # Specifying "bWaitAll" here will wait for messages *and* all events
                    # (which is pretty useless)
                    rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
                if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                    numFinished = numFinished + 1
                    if numFinished >= len(events):
                        break
                elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                    # This is critical - whole apartment model demo will hang.
                    pythoncom.PumpWaitingMessages()
                else: # Timeout
                    print("Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
            except KeyboardInterrupt:
                break
        for t in threads:
            t.join(2)
            self.failIf(t.isAlive(), "thread failed to stop!?")
        threads = None # threads hold references to args
        # Seems to be a leak here I can't locate :(
        #self.failUnlessEqual(pythoncom._GetInterfaceCount(), 0)
        #self.failUnlessEqual(pythoncom._GetGatewayCount(), 0)
trade_ebest.py 文件源码 项目:stock_trade 作者: yoonsungkim87 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_server_time():
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t0167.res")
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    dt = inXAQuery.GetFieldData('t0167OutBlock', 'dt', 0)
    tt = inXAQuery.GetFieldData('t0167OutBlock', 'time', 0)
    XAQueryEvents.queryState = 0
    return dt, tt
Windows-client.py 文件源码 项目:T2B-framework 作者: pielco11 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def WindowsHOOKER(threadName, running):
    hookman.KeyDown = OnKeyboardEvent
    hookman.HookKeyboard()
    while runHook:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.1)
Windows-client.py 文件源码 项目:T2B-framework 作者: pielco11 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def WindowsHOOKER(threadName, running):
    hookman.KeyDown = OnKeyboardEvent
    hookman.HookKeyboard()
    while runHook:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.1)
windows.py 文件源码 项目:PyUIA 作者: xiaoxiayu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run(self):
        self.hm.MouseAll = self._action
        self.hm.HookMouse()
        while self.state:
            sleep(0.01)
            pythoncom.PumpWaitingMessages()


问题


面经


文章

微信
公众号

扫码关注公众号