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.

Use generator in streaming mode

See original GitHub issue

Callbacks are not very convenient way to handle streaming. For example:

def handle_artist(_, artist):
    print(artist['name'])
    return True

xmltodict.parse(GzipFile('discogs_artists.xml.gz'),
    item_depth=2, item_callback=handle_artist)

Could look like this:

data = GzipFile('discogs_artists.xml.gz')
for _, artist in xmltodict.parse(data, item_depth=2):
    print(artist['name'])

This looks much more pythonic.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:11
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mcrowsoncommented, Jun 21, 2017

I ended up using the standard XML lib to yield dictionaries. Not in progress on my end. That original PR looked good though if you want to harvest its generator.

Sent from my iPhone

On Jun 21, 2017, at 9:05 AM, Harry Jubb notifications@github.com wrote:

Any news on this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

2reactions
mcrowsoncommented, Dec 7, 2016

it looks like #104 had generator stuff and it hasn’t been touched since May? If I pulled that out and made it a standalone PR would you accept it @martinblech ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Generators for Streaming - derp turkey
This article will discuss how you can use a Generator to efficiently stream data to a consumer. Generators are a mechanism for creating...
Read more >
Streaming Response — TurboGears 2.4.3 documentation
Streaming involves returning a generator from your controller, this will let the generator create the content while being read by client.
Read more >
Comparing the Stream API and (async) generators in Node.js ...
In this post, we will implement four infinite counters and see how streams and generators behave similarly but are fundamentally different.
Read more >
Essentia streaming mode architecture
Open-source library and tools for audio and music analysis, description and synthesis.
Read more >
Stream transformer from async generator and options
Note that using .from() does not change that the stream's source is an (async) generator, and generators process one chunk of data at...
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