Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. (....)
  2.  
  3.     def __init__(self):
  4.         self.domains = []
  5.  
  6.         try:
  7.             self.CONN = MySQLdb.connect(host=SQL_HOST,
  8.                                         user=SQL_USER,
  9.                                         passwd=SQL_PASSWD,
  10.                                         db=SQL_DB)
  11.         except MySQLdb.Error, e:
  12.             print "Error %d: %s" % (e.args[0], e.args[1])
  13.             sys.exit(1)
  14.  
  15.         self.cursor = self.CONN.cursor()
  16.         self.connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
  17.         self.channel = self.connection.channel()
  18.         self.channel.queue_declare(queue='expired', passive=False, durable=True, auto_delete=False)
  19.         self.channel.basic_qos(prefetch_count=1)
  20.         self.channel.basic_consume(self.callback, queue='expired')
  21.         logging.warning('Worker Start !')
  22.         self.channel.start_consuming()
  23.  
  24.  
  25. class Worker(multiprocessing.Process):
  26.     def run(self):
  27.         Analyse()
  28.  
  29.  
  30. if __name__ == '__main__':
  31.     jobs = []
  32.     for i in range(3):
  33.         p = Worker()
  34.         jobs.append(p)
  35.         p.daemon = False
  36.         p.start()
  37.     for j in jobs:
  38.         j.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement