question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any thoughts on supporting asyncio? Anyone working on this?

I think we could use https://github.com/hubo1016/aiogrpc to provide an asyncio version of this module.

It doesn’t necessarily have to be a fork, maybe we can create a etcd3.aio submodule or subpackage, containing async versions of the same interfaces.

Any thoughts?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
gjcarneirocommented, Jan 17, 2019

Good news, I made a small benchmarking script, it this is not much slower than the native etcd benchmarking tool, written in golang. Considering how much slower Python is compared to Go, it’s a good result.

(env37) 05:35:52 ~/projects$ python bench-etcd3-aio.py 10.128.41.79 1 2000
MAX_LATENCY:  0.020213561998389196
avg latency:  0.004505613304037979

With the native benchmark tool:

05:25:17 ~/projects$ benchmark  --endpoints=10.128.41.79:2379 put
[...]
Summary:
  Total:	39.3733 secs.
  Slowest:	0.2358 secs.
  Fastest:	0.0028 secs.
  Average:	0.0039 secs.
  Stddev:	0.0028 secs.
  Requests/sec:	253.9792

I used this test program:


import asyncio
import sys
import time

import etcd3

MAX_LATENCY = 0
TOTAL_TIME = 0
WRITES = 0


async def writer(etcd, numwrites):
    global MAX_LATENCY, TOTAL_TIME, WRITES
    for _ in range(numwrites):
        t0 = time.perf_counter()
        await etcd.put("/foo", "x" * 16)
        t1 = time.perf_counter()
        ellapsed = t1 - t0
        MAX_LATENCY = max(MAX_LATENCY, ellapsed)
        TOTAL_TIME += ellapsed
        WRITES += 1


async def main(argv):
    host = argv[1]
    numwriters = int(argv[2])
    numwrites = int(argv[3])

    etcd = etcd3.client(host=host, port=2379, timeout=10, backend="asyncio")

    writers = [writer(etcd, numwrites) for _ in range(numwriters)]
    await asyncio.gather(*writers)

    await etcd.close()
    print("MAX_LATENCY: ", MAX_LATENCY)
    print("avg latency: ", TOTAL_TIME / WRITES)


def _run():
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(main(sys.argv))
    finally:
        loop.close()


if __name__ == "__main__":
    _run()
2reactions
hroncommented, Jan 23, 2021

@tsaridas it’s not about me to merge this PR. You can check this project: https://github.com/martyanov/aetcd3. It’s based on my work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asyncio — Asynchronous I/O — Python 3.11.1 documentation
Hello World!: asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python...
Read more >
Async IO in Python: A Complete Walkthrough
Async IO is a concurrent programming design that has received dedicated support in Python, evolving rapidly from Python 3.4 through 3.7, and probably...
Read more >
Asyncio support — python-can 4.0.0 documentation
This library supports receiving messages asynchronously in an event loop using the can.Notifier class. There will still be one thread per CAN bus...
Read more >
Python Asyncio: The Complete Guide
It is proposed to make coroutines a proper standalone concept in Python, and introduce new supporting syntax. The ultimate goal is to help ......
Read more >
An introduction to asynchronous programming in Python with ...
Python 3 has a native support for async programming, Async IO, which provides a simple way to execute concurrent tasks. First, let's set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found