def start_worker(self):
if not self.include_rq:<EOL><INDENT>return None<EOL><DEDENT>worker = Worker(queues=self.queues,<EOL>connection=self.connection)<EOL>worker_pid_path = current_app.config.get(<EOL>"<STR_LIT>".format(self.config_prefix), '<STR_LIT>'<EOL>)<EOL>try:<EOL><INDENT>worker_pid_file = open(worker_pid_path, '<STR_LIT:r>')<EOL>worker_pid = int(worker_pid_file.read())<EOL>print("<STR_LIT>" % worker_pid)<EOL>worker_pid_file.close()<EOL>return worker_pid<EOL><DEDENT>except (IOError, TypeError):<EOL><INDENT>self.worker_process = Process(target=worker_wrapper, kwargs={<EOL>'<STR_LIT>': worker,<EOL>'<STR_LIT>': worker_pid_path<EOL>})<EOL>self.worker_process.start()<EOL>worker_pid_file = open(worker_pid_path, '<STR_LIT:w>')<EOL>worker_pid_file.write("<STR_LIT>" % self.worker_process.pid)<EOL>worker_pid_file.close()<EOL>print("<STR_LIT>" %<EOL>self.worker_process.pid)<EOL>return self.worker_process.pid<EOL><DEDENT>
Trigger new process as a RQ worker.