-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from childsish/asyncio
Asyncio
- Loading branch information
Showing
25 changed files
with
357 additions
and
314 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from .stream import Stream | ||
from .workflow import Workflow | ||
|
||
from .asynctools import * |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .range import AsynchronousRange | ||
from .zip import AsynchronousZip | ||
|
||
|
||
def azip(*iterables): | ||
return AsynchronousZip(*iterables) | ||
|
||
|
||
def arange(fr, to=None, step=1): | ||
return AsynchronousRange(fr, to, step) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AsynchronousRange: | ||
def __init__(self, fr, to=None, step=1): | ||
if to is None: | ||
self._iterator = iter(range(fr)) | ||
else: | ||
self._iterator = iter(range(fr, to, step)) | ||
|
||
def __aiter__(self): | ||
return self | ||
|
||
async def __anext__(self): | ||
try: | ||
return next(self._iterator) | ||
except StopIteration: | ||
raise StopAsyncIteration |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class AsynchronousZip: | ||
def __init__(self, *iterables): | ||
self._iterables = iterables | ||
|
||
def __aiter__(self): | ||
return self | ||
|
||
async def __anext__(self): | ||
res = [] | ||
for iterator in self._iterables: | ||
res.append(await iterator.__anext__()) | ||
return tuple(res) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.