python
14 minPython Runtime Advanced: Native Memory, ASGI Lifecycles, and Worker Failure
Debug memory outside Python objects, choose ASGI worker boundaries, and find silent hangs in background consumers.
Loading page...
python
14 minDebug memory outside Python objects, choose ASGI worker boundaries, and find silent hangs in background consumers.
python
17 minUnderstand event-loop scheduling, CPU versus I/O concurrency, ASGI worker lifecycles, per-request sessions, and cancellation-safe background work.
Q&A
Q&AAsync routes run on the event loop; sync routes are generally dispatched to a worker thread pool.
An async route can yield during nonblocking I/O, allowing the event loop to serve other work. A normal def route is typically run in a thread pool. Calling blocking I/O inside async def blocks the event loop; using async syntax alone does not improve CPU-bound work. Choose an execution model based on the library and bottleneck.
http
5 minKeep list traversal stable, validate cached representations, and bound retry work when networks fail at ambiguous points.
Q&A
Q&AType assertions are erased. Treat untrusted data as unknown and validate its shape and domain constraints before relying on it.
Type assertions are erased. Treat untrusted data as unknown and validate its shape and domain constraints before relying on it.
databases
6 minUse a unique ordering tuple and a deliberate visibility policy for reliable page traversal.
Q&A
Q&AInspect local socket state and bind address before changing firewall policy.
On Linux, `ss -lntup` lists listening sockets; `netstat` may be available via net-tools on older systems. Confirm the process, address, and network namespace. A service bound only to 127.0.0.1 is not externally reachable; also check container port mapping and host policy.
databases
10 minBuild common analytics queries while avoiding duplicate rows, incorrect aggregates, unstable pages, and cross-dialect surprises.