本文整理汇总了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
示例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
示例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.')
示例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()
示例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()
示例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()
示例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)
示例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()
示例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
示例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.')
示例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.')
示例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.')
示例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.')