def post(self, *args, **kwargs): app = self.checkAppAccess(args) saveAsTemplate = str(self.get_argument("saveAsTemplate", default="")) # создаем задачу из аргументов task = createTaskFromRequestArguments(self.request.arguments) session = self.getDBSession() if saveAsTemplate: # сохраняем шаблон taskTemplate = TaskTemplate() taskTemplate.appId = app.appId taskTemplate.name = self.get_argument("taskName", default=None) taskTemplate.userId = self.get_current_user().userId taskTemplate.shared = TaskTemplate.SHARED_NO session.add(taskTemplate) session.commit() # скидываем на диск taskTemplateFile = TaskTemplateFile( self.application.getTemplatePath(), task=task, taskTemplate=taskTemplate ) taskTemplateFile.baseDate = datetime.now() taskTemplateFile.save() self.redirect("/dashboard/app/{}/#templates".format(app.code)) return user = self.get_current_user() # объект для записи в базу worker = Worker() worker.userId = user.userId worker.startDate = datetime.now() worker.status = Worker.STATUS_ALIVE worker.appId = app.appId worker.name = self.get_argument("taskName", default=None) # генерируем имя запроса appService = AppService(self.application.getAppConfigPath()) appConfig = appService.getAppConfig(app.code) nameConstructor = NameConstructor(appConfig, task) if not worker.name: worker.name = nameConstructor.generateTaskName() session.add(worker) session.commit() # конструирем запрос constructor = HiveQueryConstructor(task, appConfig) querys = constructor.getHiveQuerys(worker.workerId) # task.stageCount = constructor.getStageCount() # создаем WorkerService - он будет связывать тред с файловой системой workerService = WorkerService(self.application.getResultPath(), worker) workerService.setQuery(querys) workerService.setTask(task) workerService.init() # создаем и запускаем тред workerThread = self.createHiveWorker(workerService) workerThread.start() self.redirect("/dashboard/app/" + app.code + "/#new_task/" + str(worker.workerId))