File: timeit_task.py

package info (click to toggle)
aiodogstatsd 0.16.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: python: 1,080; makefile: 70; sh: 19
file content (24 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import asyncio

import aiodogstatsd


async def do_something():
    await asyncio.sleep(1)


async def main():
    client = aiodogstatsd.Client(
        host="0.0.0.0", port=9125, constant_tags={"whoami": "I am Batman!"}
    )
    await client.connect()

    for _ in range(5000):
        await client.timeit(do_something(), "task_finished")

    await client.close()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())