编程语言
首页 > 编程语言> > python | asyncio协程写法

python | asyncio协程写法

作者:互联网

python | asyncio协程写法

贴个代码方便以后用:

if __name__ == '__main__':
	client = Pybilidanmu()
	tasks = [
		client.enter_room(),
	]
	loop = asyncio.get_event_loop()
	try:
		loop.run_until_complete(asyncio.wait(tasks))
	except KeyboardInterrupt:
		for tasks in asyncio.Task.all_tasks():
			task.cancel()
		loop.run_forever()
	
	loop.close()

标签:__,tasks,协程,python,run,loop,asyncio
来源: https://www.cnblogs.com/Mz1-rc/p/16472177.html