<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def duration(self):
 """ If the start and end times of the job are defined, return a timedelta, else return None """

        try:
            start, end = self.hmget('start', 'end')
            return parse(end) - parse(start)
        except:
            return None