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
import clickhouse_connect | |
import asyncio | |
import multiprocessing | |
import time | |
from datetime import datetime, timedelta | |
from random import randint | |
# Конфигурация подключения к ClickHouse | |
CLICKHOUSE_HOST = 'localhost' | |
CLICKHOUSE_PORT = 8123 |
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
import clickhouse_connect | |
import asyncio | |
import multiprocessing | |
import time | |
import signal | |
import sys | |
from datetime import datetime, timedelta | |
from random import randint | |
# Конфигурация подключения к ClickHouse |
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
async def callback_sessions(msg, topic): | |
pass | |
def consumer_factory(): | |
for t in topics: | |
yield AsyncJafkaConsumer(topic=t, ..., callback=partial(callback_sessions, topic=t)) | |
def run(): | |
for c in consumer_factory(): | |
asyncio.ensure_future(c.consume()) |
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
class EndpointFilter(logging.Filter): | |
def filter(self, record: logging.LogRecord) -> bool: | |
return record.getMessage().find("/endpoint") == -1 | |
# Filter out /endpoint | |
logging.getLogger("uvicorn.access").addFilter(EndpointFilter()) |
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
wsl --shutdown | |
diskpart | |
# open window Diskpart | |
select vdisk file="C:\WSL-Distros\…\ext4.vhdx" | |
attach vdisk readonly | |
compact vdisk | |
detach vdisk | |
exit |
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
import asyncio | |
import aio_pika | |
import time | |
import sys | |
async def process_message(message: aio_pika.IncomingMessage): | |
async with message.process(): | |
# worker_name = sys.argv[1] | |
print(message.body, 'queue: result', message.routing_key) |
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
import asyncio | |
async def run_periodically(wait_time, func, *args): | |
""" | |
Helper for schedule_task_periodically. | |
Wraps a function in a coroutine that will run the | |
given function indefinitely | |
:param wait_time: seconds to wait between iterations of func | |
:param func: the function that will be run | |
:param args: any args that need to be provided to func |