Command that replaces time.sleep?

I am doing a program that does the detection of colors and shapes of objects with a camera, when the format and the configured color is recognized, the program does the control of the GPIOS in which I connected a relay module. The problem I'm having is that when I use the time command.sleep to keep the relay module on, the same causes the entire program to freeze.

Here's the snippet I'm trying to solve:

if len(approx) == 4:    
  gpio.output(40 , 0)
  time.sleep(10)
  gpio.output(40, 1)
  time.sleep(5)
  cv2.putText(frame, "QUADRADO", (x, y), font, 1, (0, 255, 255) )

I'm using opencv and all control is done by a Raspberry Pi 3 B+.

Thank you for your attention friends.

Author: Henrique Komoto, 2018-12-19

1 answers

Guy like that worked for me, take a look to see if it works

from time import sleep
print("Faz algo aqui")
##dorme em segundos
sleep(1)
print("Faz outra coisa aqui")
 0
Author: João G. Hartmann, 2018-12-19 11:12:19