@provide_session<EOL><INDENT>def refresh_from_db(self, session=None, lock_for_update=False):<DEDENT>
TI = TaskInstance<EOL>qry = session.query(TI).filter(<EOL>TI.dag_id == self.dag_id,<EOL>TI.task_id == self.task_id,<EOL>TI.execution_date == self.execution_date)<EOL>if lock_for_update:<EOL><INDENT>ti = qry.with_for_update().first()<EOL><DEDENT>else:<EOL><INDENT>ti = qry.first()<EOL><DEDENT>if ti:<EOL><INDENT>self.state = ti.state<EOL>self.start_date = ti.start_date<EOL>self.end_date = ti.end_date<EOL>self.try_number = ti._try_number<EOL>self.max_tries = ti.max_tries<EOL>self.hostname = ti.hostname<EOL>self.pid = ti.pid<EOL>self.executor_config = ti.executor_config<EOL><DEDENT>else:<EOL><INDENT>self.state = None<EOL><DEDENT>
Refreshes the task instance from the database based on the primary key

:param lock_for_update: if True, indicates that the database should
    lock the TaskInstance (issuing a FOR UPDATE clause) until the
    session is committed.