Python
What is the pattern called where `Engine` is created once for the application and manages a shared connection pool?
How does `Depends(get_db)` work in the context of FastAPI endpoint, and why is dependency injection mechanism needed?
broker = KafkaBroker("localhost:9092") app = FastStream(broker) @broker.subscriber("raw_texts_topic", group_id="text_parsers") async def handle_text(text_data: dict): # Парсинг и сохранение в БД занимает ~10 секунд parse_text_and_save_to_postgres(text_data)
# How long does it take for asyncio.run(main()) to execute?
What is the object returned by a function with `yield`, and what return type annotation is suitable here instead of `list[str]`?
def extract_emails_from_huge_file(file_path: str) -> list[str]: with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Заменяем переносы строк, чтобы текст был "сплошным" content = content.replace('\r\n', ' ').replace('\n', ' ') lines = content.split(' ') emails = [word for word in lines if '@' in word] return emails
How to prevent reprocessing of the same Kafka message? Where and how to organize idempotency check on the consumer side?
Are you still working at Toca?