blivedm/sample.py

26 lines
525 B
Python
Raw Normal View History

2018-05-13 21:57:36 +08:00
# -*- coding: utf-8 -*-
import asyncio
from time import time
from blivedm import DanmuPrinter
async def test1():
connection = DanmuPrinter(23058, 0)
task_run = asyncio.ensure_future(connection.run_forever())
await asyncio.sleep(30)
print(time(), 'closing')
await connection.close()
print(time(), 'closed')
await task_run
print(time(), 'all done')
2018-05-13 21:57:36 +08:00
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(test1())
loop.close()
2018-05-13 21:57:36 +08:00
if __name__ == '__main__':
main()