All fields

“Async Generators & Async Context Managers” in Information Technology

24 questions across 1 technology.

Information Technology

24 questions in 1 technology

#QuestionTechnologyTopicLevel
1How do you correctly test async generators and async context managers using pytest and pytest-asyncio? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
2What is an async context manager, and which two dunder methods does it require? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersBeginner
3How do async generators interact with asyncio.Queue to implement a producer-consumer pattern across separate tasks? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
4How would you implement a 'fan-out, fan-in' pattern using multiple async generators consumed concurrently and merged into one stream? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
5How do you write an async context manager more concisely using @contextlib.asynccontextmanager? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
6How does an async generator interact with try/finally for guaranteed cleanup, similar to regular generators? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
7How would you implement an async context manager that also supports being used as a decorator, similar to contextlib.contextmanager's decorator support? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
8What is an async generator, and how does it differ from a regular generator? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersBeginner
9How do you consume an async generator using 'async for'? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersBeginner
10How do you build an async generator pipeline, chaining one async generator's output into another, like a synchronous generator pipeline? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
11How do async comprehensions work, combining 'async for' directly inside a list/set/dict comprehension? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
12How do you handle backpressure when an async generator produces items faster than the consumer can process them? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
13How would you implement a custom async iterator class from scratch, without using an async generator function? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
14How would you implement timeout handling for an async generator's individual yields, so a stalled source doesn't hang the consumer forever? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
15How do you properly propagate cancellation into an async generator when the consuming task is cancelled mid-iteration? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
16How would you implement asynchronous file I/O using aiofiles alongside an async context manager, to avoid blocking the event loop during file operations? Python › File I/O & Context ManagersPythonFile I/O & Context ManagersAdvanced
17What is the basic pattern for running an async function using asyncio.run()? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Beginner
18How do you run multiple coroutines concurrently using asyncio.gather()? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Intermediate
19How does asyncio's event loop schedule and switch between multiple coroutines, and what makes this cooperative rather than preemptive? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Advanced
20How do you safely run a blocking, synchronous function from within an asyncio coroutine without freezing the event loop? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Advanced
21What is the relationship between generators and the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
22How do you include structured context (like a request ID) in every log message using LoggerAdapter or extra? Python › LoggingPythonLoggingIntermediate
23How do you write a decorator that works correctly on an async function (coroutine), given that a regular decorator's wrapper would break 'await' usage? Python › DecoratorsPythonDecoratorsAdvanced
24What exception signals the end of iteration, and how does a for-loop use it internally? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner