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
| # -*- coding: utf-8 -*- | |
| """ | |
| @Time : 2021/10/3 19:18 | |
| @Auth : d1rrick DanielGao.eth | |
| @File :autochat.py | |
| @IDE :vscode | |
| """ | |
| import requests | |
| import json |
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 functools import wraps | |
| def dec(fn): | |
| @wraps(fn) | |
| async def wrapper(*args, **kwargs): | |
| print(fn, args, kwargs) # <function foo at 0x10952d598> () {} | |
| await asyncio.sleep(5) |
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
| """ | |
| Example of redis channels pub/sub for aiohttp microservices using aioredis | |
| Another example - https://aioredis.readthedocs.io/en/latest/examples.html#pub-sub-example | |
| """ | |
| """ | |
| Service pub. | |
| Publish some json test data into channel by api call |
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
| # -*- coding: utf-8 -*- | |
| import asyncio | |
| import uvloop | |
| from aiohttp.web import Application, MsgType, WebSocketResponse | |
| def add_socket(app, socket, user_id): | |
| if user_id in app['connections']: | |
| pass |