Mixing coroutines and generators?

37 views
Skip to first unread message

cr0hn

unread,
Nov 8, 2019, 6:21:44 AM11/8/19
to python-tulip
Hello everybody:

I'm trying to write a Python code that mixing coroutines and
generator, but I don't know if this make sense. Here the example:

async def load_previous_data(redis: aioredis.Redis,
channel: str,
count: int = 20):

result = await redis.xrange(channel, count=count, stop="+")

key, values_raw = result[0]

for k, v in values_raw.items():
yield k.decode("UTF-8"): v.decode("UTF-8")


Could anybody help me?

Thanks in advance


--
Daniel García a.k.a. cr0hn - Security researcher and pentester
@ggdaniel
http://www.cr0hn.com/me/

Gustavo Carneiro

unread,
Nov 8, 2019, 6:30:08 AM11/8/19
to cr0hn, python-tulip
Yes, this is called "async generator", see https://www.python.org/dev/peps/pep-0525/

--
You received this message because you are subscribed to the Google Groups "python-tulip" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tulip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-tulip/CAO5w5vbAx0UO9SD2Uy9iWRBh7z8P%3DWRDBv53%3D_3vg_HzCVOQvw%40mail.gmail.com.


--
Gustavo J. A. M. Carneiro
Gambit Research
"The universe is always one step beyond logic." -- Frank Herbert

cr0hn

unread,
Nov 8, 2019, 6:31:00 AM11/8/19
to Gustavo Carneiro, python-tulip
Thanks a lot!

El vie., 8 nov. 2019 a las 12:30, Gustavo Carneiro
(<gjcar...@gmail.com>) escribió:
Reply all
Reply to author
Forward
0 new messages