import gevent def my_function(): while True: print("Hello World!") gevent.sleep(1) g = gevent.spawn(my_function) # Terminate the Greenlet after 5 seconds gevent.sleep(5) g.kill()In this example, we create a Greenlet object using gevent.spawn(), which invokes the function my_function(). Inside the function, we print "Hello World!" every second using gevent.sleep(). After 5 seconds, we terminate the Greenlet by calling g.kill(). The package library used in this example is gevent.