Senior
"""Task 1. Asynchronous function decorator Implement a decorator for an asynchronous function that logs the start time of its execution. For simplicity, logging can be done by printing a message. Konstantin 10:18 """ def log_start_time(…): """ Decorator for logging the start time of an asynchronous function """ # TODO: YOUR CODE HERE
sobes.tech AI
Answer from AI
python import functools import datetime
def log_start_time(func): @functools.wraps(func) async def wrapper(*args, **kwargs): print(f"Start of {func.name} at {datetime.datetime.now()}") return await func(*args, **kwargs) return wrapper
Example usage:
@log_start_time async def example(): await asyncio.sleep(1)