Freezing Time with Sleep and Printing Argument

  • Share this:

Code introduction


This function uses the freeze_time feature from the Freezegun library to freeze time, performs a sleep operation within the frozen time, and finally prints the third parameter passed in.


Technology Stack : Freezegun

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random
from freezegun import freeze_time

def random_freeze_time(arg1, arg2, arg3):
    with freeze_time(arg1):
        time.sleep(arg2)
        print(arg3)                
              
Tags: