Simple example of stream with Asyncio operations
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- stream-processing
Hướng nghiên cứu
Start by reproducing the Python example from the issue with its aiohttp, asyncio, and Stream(asynchronous=True) pipeline. Read the streamz asyncio-related implementation and existing tests, if present, to determine whether async map operations are supported. Done means the reported pipeline runs correctly or the supported limitation is documented.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
I've been following the docs and reading through the tests, and I cannot get streamz working with Asyncio :/
Here's a very minimal example of a stream comprising of two async operation and one sync :
- we retrieve content via an aiohttp call
- return content length
- simulate DB write with an Asyncio sleep
- sink to stdout
import asyncio
import aiohttp
from streamz import Stream
async def fetch(url):
print("fetching url {}", url)
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
print(resp.status)
body = await resp.text()
print("Finished w/ url {}", url)
return body
def count(x):
print("I", x)
return len(x)
async def write(x):
await asyncio.sleep(0.2)
print("O", x)
return x
async def f():
print("Starting stream")
source = Stream(asynchronous=True)
source.map(fetch).map(count).map(write).sink(print)
urls = [
'https://httpstatus.io/?i=1',
'https://httpstatus.io/?i=2',
'https://httpstatus.io/?i=3',
'https://httpstatus.io/?i=4',
'https://httpstatus.io/?i=5',
'https://httpstatus.io/?i=6',
]
for u in urls:
await source.emit(u)
if __name__ == '__main__':
asyncio.run(f())
I've tried a lot of combinations using tornado event loop etc. but didn't manage to get anything working.
Is this supposed to be possible or is the Asyncio support still behind?
Am I missing something obvious?
Thanks for the help
- Ngôn ngữ chính
- Python
- Star
- 1.3k
- Fork
- 149
- Merge trung bình
- 17 giờ 39 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-streamz/streamz
-
pkg_resources warning Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
python-streamz/streamz#481 · 4 bình luận ·
-
Combining the streamz.Stream.filenames() and streamz.Stream.from_textfile() using dask scatter? Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
python-streamz/streamz#480 · 2 bình luận ·
-
Compile the code into c++ Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
python-streamz/streamz#479 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
python-streamz/streamz#478 · 6 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 10/100
python-streamz/streamz#476 · 17 bình luận · 2 reaction ·
Tất cả issue của python-streamz/streamz
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·