Advertisement
richigarza

main.py

Sep 5th, 2012
1,371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. #!/usr/bin/python
  2. import time, threading
  3. from eliminar import eliminar
  4. from insertar import insertar
  5.  
  6. class main(threading.Thread):
  7.    
  8.  
  9.     def __init__(self):
  10.         threading.Thread.__init__(self)
  11.         self.semaforo1 = []
  12.         self.semaforo2 = []
  13.         self.semaforo3 = []
  14.         self.semaforos = [self.semaforo1,self.semaforo2,self.semaforo3]
  15.  
  16.     def run(self):
  17.         contador = 1
  18.         while contador <= 3:
  19.        
  20.             while True:
  21.                 insertar(self.semaforos)
  22.                 tiempo = 5
  23.    
  24.                 while len(self.semaforo1) > 0:
  25.                     while tiempo > 0:
  26.                         eliminar(self.semaforo1)
  27.                         print "se elimino un carro del carril 1: " ,self.semaforo1
  28.                         tiempo -= 1
  29.                         print "le quedan " ,tiempo, " segundos al semaforo 1"
  30.                         time.sleep(1)
  31.                         break
  32.                     tiempo = len(self.semaforo1) + 1
  33.  
  34.                 while len(self.semaforo2) > 0:
  35.                     while tiempo > 0:
  36.                         eliminar(self.semaforo2)
  37.                         print "se elimino un carro del carril 2: " ,self.semaforo2
  38.                         tiempo -= 1
  39.                         print "le quedan " ,tiempo, " segundos al semaforo 2"
  40.                         time.sleep(1)
  41.                         break
  42.                     tiempo = len(self.semaforo2) + 1
  43.  
  44.                 while len(self.semaforo3) > 0:
  45.                     while tiempo > 0:
  46.                         eliminar(self.semaforo3)
  47.                         print "se elimino un carro del carril3 : " ,self.semaforo3
  48.                         tiempo -= 1
  49.                         print "le quedan " ,tiempo, " segundos al semaforo 3"
  50.                         time.sleep(1)
  51.                         break
  52.                     tiempo = len(self.semaforo3) + 1
  53.  
  54. me=main()
  55. me.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement