当前位置: 首页>>代码示例>>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;未经允许,请勿转载。