| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Running the network word count example showed an attempt to await a list object in the Tornado framework. I tracked it down to the EmitServer.handle_stream assuming the result of source._emit was awaitable. Pivoting on inspect.isawaitable there makes the example as written work. I added a try/except block to trap the keyboard interrupt and suppress the stack spew to the example.
* Change the examples to only seed with the value 1
* The thread example blocks on emit due to the cycle in the stream
so it CAN only seed with one value.
* Take all explicit references to Tornado out of the asyncio variant
* Suppress the stack spew from KeyboardException
* Ensure all variants have the same output
Using BeautifulSoup4 and making sure to filter out empty lists before feeding them flatten, this runs again.
Trap the StopIteration that erupts from update when passed an empty iterable so that the stream can continue.
|
Thank you, and I have not forgotten #493 either. There is some code to ensure that if any of the nodes are asynchronous, then all of them should be. So _emit not returning an awaitable - that happens in the case that a node cannot be async? Is there an argument that streamz should standardise on async nodes only? |
Sorry, something went wrong.
The from_tcp and _emit fix I included came from the network word count example. It was the most expedient way of getting the example working. From going back through the code around Source/Stream creation, it seems that the example as written guarantees that the resultant stream is synchronous: streamz/examples/network_wordcount.py Lines 10 to 11 in 8c73290 Line 40 in 8c73290 Lines 258 to 259 in 8c73290 I believe that is why the _emit call was not returning an Awaitable and the server ended up killing the socket when trying to await it anyway. As far as I understand the deeper plumbing of Stream, this was executing the actual work in an event loop just in a different thread and so the stream itself was returning the end result instead of a Task representing the work and subsequent result.
I think as a framework there is probably value in both threaded and asyncio support. The asyncio module/design appears to be fairly polarizing in the larger Python ecosystem. A significant number of projects that I run into in the wild forswear it entirely while others are asyncio-only. Our historical code is non-asyncio/multiprocessing and our more current work is all asyncio-native. We've definitely had difficulties supporting both. |
Sorry, something went wrong.
There was a problem hiding this comment.
This all looks very good.
Sorry, something went wrong.
| .map(links_of_page) | ||
| .concat()) | ||
| links.sink(source.emit) | ||
| .flatten()) |
There was a problem hiding this comment.
I saw the improvement to flatten(), but was concat() wrong, or did it disappear?
Sorry, something went wrong.
There was a problem hiding this comment.
The concat and scan aliases for flatten and accumulate are still there but they do not show up in the documentation so I switched the examples to use flatten directly since it is documented.
Sorry, something went wrong.
| .concat()) | ||
| links.sink(source.emit) | ||
| .flatten()) | ||
| links.connect(source) |
There was a problem hiding this comment.
Yes, this is more right than sink(emit).
Sorry, something went wrong.
|
|
||
| IOLoop.current().start() | ||
| try: | ||
| IOLoop.current().start() |
There was a problem hiding this comment.
Should default to using asyncio?
Sorry, something went wrong.
There was a problem hiding this comment.
I was trying to preserve the Tornado semantics of the example as they are still valid and there is obviously quite a bit of example material in the documentation using Tornado.
Sorry, something went wrong.
|
|
||
|
|
||
| source = Stream() | ||
| source = Stream(asynchronous=True) |
There was a problem hiding this comment.
At least one of these should be rewritten (or alternative version added) in an aync def function as an example where the whole app is a single asyncio.run() call.
Sorry, something went wrong.
There was a problem hiding this comment.
Initially, I did that for fib_asyncio.py but then it looked heavy-weight compared to the tornado variant and lost some of the ease of direct comparison.
Sorry, something went wrong.
|
@dwskoog , do you have any interest in being involved with longer-term maintenance of this repo? |
Sorry, something went wrong.
At the very least, there are some major improvements that would make my professional life better that I would like to see done and that means doing them myself. For example, a MyPy plugin to handle comprehension of the registration mechanism since MyPy has no plans to handle that. and PEP-484 support. One aspect of Akka/Pekko Streams that I miss is clearly understanding the input and output shapes along the graph nodes at a glance. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I found two bugs in the main code by refreshing the examples to work under the current API:
Example refreshes:
Unit tests: