Last active
April 14, 2022 08:53
-
-
Save vitaliihonta/b9be77deb0dfea1e9a411e695e6f15c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aiohttp.client import ClientSession | |
from aiohttp.streams import AsyncStreamIterator | |
from functools import partial | |
import asyncio | |
async def main(): | |
async with ClientSession() as session: | |
# use the file from gist below | |
url = "https://gist.githubusercontent.com/vitaliihonta/b9be77deb0dfea1e9a411e695e6f15c9/raw/5fbf72842bff7f74ce06479d7e0d06f5af334f86/example.txt" | |
async with session.get(url) as resp: | |
async for line in AsyncStreamIterator(partial(resp.content.readuntil, b'ab')): | |
print(line) | |
if __name__ == '__main__': | |
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11ab | |
22ab | |
33ab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment