Add timeout context manager for functions