Sobes.tech

from fastapi import FastAPI, UploadFile, Response from fastapi.responses import StreamingResponse from pydantic import BaseModel, field_validator import base64 app = FastAPI() class PdfSchema(BaseModel): filename: str content_type: str data: str # base64 pdf 10мб @app.get("/data", response_model=PdfSchema) async def get_data(): return await service.get_big_data() @app.get("/download") async def download(): with open("big.pdf", "rb") as f: data = f.read() return Response(content=data, media_type="application/pdf") def heavy_pdf_parse(data: bytes) -> dict: # CPU-heavy логика return {"size": len(data)} @app.post("/parse") async def parse(file: UploadFile): content = await file.read() result = heavy_pdf_parse(content) return result @app.get("/users") async def get_users(): users = await repo.get_users() result = [] for u in users: posts = await repo.get_posts(u["id"]) result.append({"user": u, "posts": posts}) return result @app.get("/download-two") async def download_two(): def iterfile(): with open("big.pdf", "rb") as f: yield from f return StreamingResponse(iterfile(), media_type="application/pdf") class service: @staticmethod async def get_big_data(): return { "filename": "file.pdf", "content_type": "application/pdf", "data": base64.b64encode(b"fake").decode(), } class repo: @staticmethod async def get_users(): return [{"id": 1}, {"id": 2}] @staticmethod async def get_posts(user_id: int): return [{"id": 1, "user id": user_id}]

Middle
125

Why are mutexes needed in Python if GIL already guarantees single-threadedness?

Senior
125

Do you have a duty shift? How did you connect when there were problems on the backend?

Middle+
125

What data types are there in Python? Tell me about mutable and immutable types.

Middle
125

A microservice started consuming 100% CPU on all 20 cores after a new release. How would you identify the problem?

Middle
125

Why does the quicksort function use the condition len(arr) <= 1?

Junior
125

Find the character that appears consecutively most often in the string.

Senior
124

What is the difference between threads and processes?

Middle+
124

Who configured alerts and how does a service degradation turn into an alert?

Middle+
124

What is a generator? Why is it needed in Python?

Middle
124

In a FastAPI service with model inference on PyTorch — what is better to choose: ThreadPool or ProcessPool?

Middle
124

What are HTTP status codes? Name the main ones.

Middle+
124

What does the process from commit to deployment on the stands look like?

Middle+
123

Why does multithreading still work with IO-bound tasks despite the GIL?

Middle+
123

How are floating point numbers (float) structured?

Senior
123

Can you describe the main responsibilities and projects you worked on at your previous job?

Junior — Middle
123

What is a Dockerfile and what is it used for?

Middle+
123

How did you keep the cache consistent in catalog and cart services — when invalidating, how was it organized?

Senior
123

Tell me about decorators and generators. Write a retry decorator with parameters.

Middle+
123

What was the basis for determining the intent and where to redirect the user in your bot?

Middle
122
/20