<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def close(self):
 """ Release all resources associated with this factory. """

        if self.mdr is None:
            return
        exc = (None, None, None)
        try:
            self.cursor.close()
        except:
            exc = sys.exc_info()
        try:
            if self.mdr.__exit__(*exc):
                exc = (None, None, None)
        except:
            exc = sys.exc_info()
        self.mdr = None
        self.cursor = None
        if exc != (None, None, None):
            six.reraise(*exc)