當前位置: 首頁>>代碼示例>>Python>>正文


Python uasyncio.new_event_loop方法代碼示例

本文整理匯總了Python中uasyncio.new_event_loop方法的典型用法代碼示例。如果您正苦於以下問題:Python uasyncio.new_event_loop方法的具體用法?Python uasyncio.new_event_loop怎麽用?Python uasyncio.new_event_loop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在uasyncio的用法示例。


在下文中一共展示了uasyncio.new_event_loop方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    print('Test for IR receiver. Assumes NEC protocol.')
    print('ctrl-c to stop.')
    if platform == 'pyboard':
        p = Pin('X3', Pin.IN)
    elif platform == 'esp8266':
        freq(160000000)
        p = Pin(13, Pin.IN)
    elif ESP32:
        p = Pin(23, Pin.IN)
    ir = NEC_IR(p, cb, True)  # Assume r/c uses extended addressing
    loop = asyncio.get_event_loop()
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()  # Still need ctrl-d because of interrupt vector 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:20,代碼來源:art.py

示例2: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    print('Test for IR receiver. Assumes NEC protocol. Turn LED on or off.')
    if platform == 'pyboard':
        p = Pin('X3', Pin.IN)
        led = LED(2)
    elif platform == 'esp8266':
        freq(160000000)
        p = Pin(13, Pin.IN)
        led = Pin(2, Pin.OUT)
        led(1)
    elif ESP32:
        p = Pin(23, Pin.IN)
        led = Pin(21, Pin.OUT)  # LED with 220Ω series resistor between 3.3V and pin 21
        led(1)
    ir = NEC_IR(p, cb, True, led)  # Assume extended address mode r/c
    loop = asyncio.get_event_loop()
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()  # Still need ctrl-d because of interrupt vector 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:24,代碼來源:art1.py

示例3: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    try:
        asyncio.run(main())
    finally:  # Reset uasyncio case of KeyboardInterrupt
        asyncio.new_event_loop()
        print('asnano_sync.test() to re-run test.') 
開發者ID:peterhinch,項目名稱:micropython-nano-gui,代碼行數:8,代碼來源:asnano_sync.py

示例4: run

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def run():
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        print('Closing sockets')
        server.Connection.close_all()
        asyncio.new_event_loop() 
開發者ID:peterhinch,項目名稱:micropython-iot,代碼行數:11,代碼來源:s_app.py

示例5: run

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def run():
    clients = {'rx', 'tx'}  # Expected clients
    apps = [App(name) for name in clients]  # Accept 2 clients
    try:
        asyncio.run(server.run(clients, verbose=True, port=PORT, timeout=TIMEOUT))
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        print('Closing sockets')
        server.Connection.close_all()
        asyncio.new_event_loop() 
開發者ID:peterhinch,項目名稱:micropython-iot,代碼行數:13,代碼來源:s_comms_cp.py

示例6: change

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def change(cls, cls_new_screen, *, forward=True, args=[], kwargs={}):
        init = cls.current_screen is None
        if init:
            Screen() # Instantiate a blank starting screen
        else:  # About to erase an existing screen
            for entry in cls.current_screen.tasklist:
                if entry[1]:  # To be cancelled on screen change
                    entry[0].cancel()
        cs_old = cls.current_screen
        cs_old.on_hide() # Optional method in subclass
        if forward:
            if isinstance(cls_new_screen, ClassType):
                new_screen = cls_new_screen(*args, **kwargs) # Instantiate new screen
            else:
                raise ValueError('Must pass Screen class or subclass (not instance)')
            new_screen.parent = cs_old
            cs_new = new_screen
        else:
            cs_new = cls_new_screen # An object, not a class
        cls.current_screen = cs_new
        cs_new.on_open() # Optional subclass method
        cs_new._do_open(cs_old) # Clear and redraw
        cs_new.after_open() # Optional subclass method
        if init:
            try:
                asyncio.run(Screen.monitor())  # Starts and ends uasyncio
            finally:
                asyncio.new_event_loop()
                gc.collect() 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:31,代碼來源:ugui.py

示例7: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    try:
        asyncio.run(adctest())
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print()
        print(st) 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:11,代碼來源:adctest.py

示例8: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test(n=0):
    try:
        asyncio.run(tests[n]())
    finally:
        asyncio.new_event_loop() 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:7,代碼來源:delay_test.py

示例9: run

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def run():
    try:
        asyncio.run(killer())
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print(tests)


# Test for the Switch class passing coros 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:13,代碼來源:switches.py

示例10: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test(rex):
    st = exp_true if rex else exp_false
    printexp(st)
    try:
        asyncio.run(main(rex))
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print()
        print('as_demos.gather.test() to run again.')
        print('as_demos.gather.test(True) to see effect of return_exceptions.') 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:14,代碼來源:gather.py

示例11: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print('as_demos.auart.test() to run again.') 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:10,代碼來源:auart.py

示例12: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test(duration=10):
    try:
        asyncio.run(main(duration))
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print('as_demos.aledflash.test() to run again.') 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:10,代碼來源:aledflash.py

示例13: test

# 需要導入模塊: import uasyncio [as 別名]
# 或者: from uasyncio import new_event_loop [as 別名]
def test():
    printexp()
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()
        print('as_demos.auart_hd.test() to run again.') 
開發者ID:peterhinch,項目名稱:micropython-async,代碼行數:11,代碼來源:auart_hd.py


注:本文中的uasyncio.new_event_loop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。