code: def dump(self, directory=''):
          
          with self.no_unpicklable_properties():
              file_name = os.path.join(directory, 'job-instance.pickle')
              if self.__module__ == '__main__':
                  d = pickle.dumps(self)
                  module_name = os.path.basename(sys.argv[0]).rsplit('.', 1)[0]
                  d = d.replace(b'(c__main__', "(c" + module_name)
                  open(file_name, "wb").write(d)
  
              else:
                  pickle.dump(self, open(file_name, "wb"))
docs: Dump instance to file.