-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc: implement python async iterator
- Loading branch information
Showing
7 changed files
with
211 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys | ||
import asyncio | ||
from rpc_reader import prepare_peer_readloop | ||
|
||
async def main(): | ||
peer, peerReadLoop = await prepare_peer_readloop(loop, 4, 3) | ||
peer.params['foo'] = 3 | ||
|
||
async def ticker(delay, to): | ||
for i in range(to): | ||
# print(i) | ||
yield i | ||
await asyncio.sleep(delay) | ||
|
||
peer.params['ticker'] = ticker(0, 3) | ||
|
||
print('python starting') | ||
await peerReadLoop() | ||
|
||
loop = asyncio.new_event_loop() | ||
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
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
Oops, something went wrong.