Skip to content

Instantly share code, notes, and snippets.

@evanxg852000
Last active January 9, 2020 17:53
Show Gist options
  • Save evanxg852000/206d7c84c049fff1e8446457c48b5771 to your computer and use it in GitHub Desktop.
Save evanxg852000/206d7c84c049fff1e8446457c48b5771 to your computer and use it in GitHub Desktop.
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