Last active
January 9, 2020 17:53
-
-
Save evanxg852000/206d7c84c049fff1e8446457c48b5771 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import asyncio | |
from resp import Client | |
async def main_client(prompt, evt_loop): | |
print(f'{prompt} Welcome to pyRedis') | |
running = True | |
cl = Client(evt_loop) | |
while running: | |
cmd = input(f'{prompt} ') | |
if cmd == '.exit': | |
running = False | |
else: | |
try: | |
reply = await cl.execute(cmd) | |
print(prompt, reply) | |
except Exception as e: | |
print(prompt, 'errr:', e) | |
cl.close() | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main_client('$pyredis>>', loop)) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment