2018-05-13 21:57:36 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-02-17 17:01:52 +08:00
|
|
|
import asyncio
|
|
|
|
from time import time
|
2019-02-14 18:36:37 +08:00
|
|
|
from blivedm import DanmuPrinter
|
2018-06-03 14:06:00 +08:00
|
|
|
|
2019-02-17 17:01:52 +08:00
|
|
|
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():
|
2019-02-17 17:01:52 +08:00
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.run_until_complete(test1())
|
2019-02-14 18:36:37 +08:00
|
|
|
loop.close()
|
2018-05-13 21:57:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|