Beispiel #1
0
 def run(self):
     self.init()
     # 监听指令
     commands = ztq_core.get_command_queue(self.worker_name)
     while True:
         try:
             command = commands.pop()
             if command['command'] == 'report':
                 worker_state = ztq_core.get_worker_state()
                 worker_state[self.worker_name] = report(self.login_time)
             elif command['command'] == 'updatedriver':
                 # TODO
                 #async_drive_config()
                 pass
             elif command['command'] == 'updateworker':
                 queue = ztq_core.get_worker_config()
                 set_job_threads(queue[self.worker_name])
             elif command['command'] == 'kill':
                 kill_transform(pid=command['pid'], timestamp=command['timestamp'])
             elif command['command'] == 'cancel':
                 cancel_transform(pid=command['pid'], timestamp=command['timestamp'])
         except KeyboardInterrupt:
             import os
             # 实际上调用的是command_execute.clear_thread
             os.sys.exitfunc()
             os._exit(0)
Beispiel #2
0
 def run(self):
     self.init()
     # 监听指令
     commands = ztq_core.get_command_queue(self.worker_name)
     while True:
         try:
             command = commands.pop()
             if command['command'] == 'report':
                 worker_state = ztq_core.get_worker_state()
                 worker_state[self.worker_name] = report(self.login_time)
             elif command['command'] == 'updatedriver':
                 # TODO
                 #async_drive_config()
                 pass
             elif command['command'] == 'updateworker' and \
                     CONFIG['server'].get('active_config', 'false').lower() == 'true':
                 queue = ztq_core.get_worker_config()
                 set_job_threads(queue[self.worker_name])
             elif command['command'] == 'kill':
                 kill_transform(pid=command['pid'], timestamp=command['timestamp'])
             elif command['command'] == 'cancel':
                 cancel_transform(pid=command['pid'], timestamp=command['timestamp'])
         except ztq_core.ConnectionError, e:
             logger.error('ERROR: redis command connection error: %s' % str(e))
             time.sleep(3)
         except ztq_core.ResponseError, e:
             logger.error('ERROR: redis command response error: %s' % str(e))
             time.sleep(3)
Beispiel #3
0
 def run(self):
     self.init()
     # 监听指令
     commands = ztq_core.get_command_queue(self.worker_name)
     while True:
         try:
             command = commands.pop()
             if command['command'] == 'report':
                 worker_state = ztq_core.get_worker_state()
                 worker_state[self.worker_name] = report(self.login_time)
             elif command['command'] == 'updatedriver':
                 # TODO
                 #async_drive_config()
                 pass
             elif command['command'] == 'updateworker':
                 queue = ztq_core.get_worker_config()
                 set_job_threads(queue[self.worker_name])
             elif command['command'] == 'kill':
                 kill_transform(pid=command['pid'],
                                timestamp=command['timestamp'])
             elif command['command'] == 'cancel':
                 cancel_transform(pid=command['pid'],
                                  timestamp=command['timestamp'])
         except KeyboardInterrupt:
             import os
             # 实际上调用的是command_execute.clear_thread
             os.sys.exitfunc()
             os._exit(0)