Enqueue instance delete if it's no longer in the db
549989
def delete_instance_if_removed(self, port):
        """"""
        instance_type = self.get_instance_type(port)
        if not instance_type:
            return
        if not db_lib.instance_provisioned(port['device_id']):
            i_res = MechResource(port['device_id'], instance_type,
                                 a_const.DELETE)
            self.provision_queue.put(i_res)
829261
async def clear(self, using_db=None) -> None:
        
        db = using_db if using_db else self.model._meta.db
        through_table = Table(self.field.through)
        query = (
            db.query_class.from_(through_table)
            .where(getattr(through_table, self.field.backward_key) == self.instance.id)
            .delete()
        )
        await db.execute_query(str(query))
1195459
def delete(self, for_update=False):
        
        hash_key = self.get_hash_id()
        try:
            original_instance = self.load(hash_key, convert_key=False)
        except KeyError:
            return

        # Remove from the `all` index.
        all_index = self._query.all_index()
        all_index.remove(hash_key)

        # Remove from the secondary indexes.
        for field in self._indexes:
            for index in field.get_indexes():
                index.remove(original_instance)

        if not for_update:
            for field in self._fields.values():
                if isinstance(field, _ContainerField):
                    field._delete(self)

        # Remove the object itself.
        self.__database__.delete(hash_key)
1046166
def versionable_delete(self, instance, timestamp):
        
        instance._delete_at(timestamp, using=self.using)
256421
def delete_instance(model, instance_id, _commit=True):
    
    try:
        model = get_model(model)
    except ImportError:
        return

    instance = model.query.get(instance_id)
    if not instance:
        return

    db.session.delete(instance)
    try:
        if _commit:
            db.session.commit()
        else:
            db.session.flush()
    except Exception as exception:
        db.session.rollback()
        raise exception
896680
def delete(instance_id, profile=None, **kwargs):
    '''
    

    '''
    conn = _auth(profile, **kwargs)
    return conn.delete(instance_id)
554265
static function cleanup()
    {
        $availableHandlers = eZNotificationEventFilter::availableHandlers();

        $db = eZDB::instance();
        $db->begin();
        foreach( $availableHandlers as $handler )
        {
            if ( $handler !== false )
            {
                $handler->cleanup();
            }
        }
        $db->commit();
    }
838399
protected function queueAllForDeletion()
    {
        if (empty($this->getAttribute('filename'))) {
            return;
        }

        // Remove old files
        if ($this->config('preserve_files', false) === false) {
            foreach ($this->styles as $name => $style) {
                $this->setQueue('deletion', $this->path($name));
            }
        }

        // Set model attributes
        $this->instanceWrite('file_name', null);
        $this->instanceWrite('file_size', null);
        $this->instanceWrite('content_type', null);
        $this->instanceWrite('updated_at', null);
        $this->instanceWrite('queue_state', self::QUEUE_DONE);
        $this->instanceWrite('queued_file', null);
    }
132804
static function CleanUp()
	{
		$limit = new \DateTime('-30 minutes');
		foreach(self::$instances as $login => $player)
			if($player->awaySince && $player->awaySince < $limit) unset(self::$instances[$login]);
	}
1190413
function closeDatabase (name) {
  var deferred = q.defer();

  // We need to be sure the database location exists
  ready.then(function () {
    clearTimeout(timeouts[name]);

    // Write to file
    write(name).then(function () {
      // Remove database from memory
      delete databases[name];

      deferred.resolve();
    }, function (err) {
      deferred.reject(err);
    });
  }, function () {
    deferred.reject('Database couldn\'t instantiate');
  });

  return deferred.promise;
}
1220895
def stop_instance(self, instance_id):
        
        instance = self._load_instance(instance_id)
        instance.delete()
        del self._instances[instance_id]
1354438
def delete_object(self, obj):
        
        session = self.get_db_session()
        session.delete(obj)
        session.commit()
768410
def cleardb(force=False):
    """"""

    # Drop database, if it exists
    if db_exists():
        try:
            dropdb(force)
        except subprocess.CalledProcessError as error:
            output = error.output.decode("utf-8")
            if "is being accessed by other users" in output:
                raise ValueError(
                    "{}\n"
                    "To forcibly terminate other sessions, run "
                    "this command again with --force".format(output)
                )
            else:
                raise
    else:
        logger.info(
            "Database %s does not currently exist; no need to drop", repr(DB["NAME"])
        )
    createdb()
246402
public void deleteInstance() {
    System.out.println("\nDeleting Instance");
    // [START bigtable_delete_instance]
    try {
      adminClient.deleteInstance(instanceId);
      System.out.println("Instance deleted: " + instanceId);
    } catch (NotFoundException e) {
      System.err.println("Failed to delete non-existent instance: " + e.getMessage());
    }
    // [END bigtable_delete_instance]
  }
12061
private static void purgeQueue() {

        ChronoReference cref;

        while ((cref = (ChronoReference) QUEUE.poll()) != null) {
            for (ChronoReference test : CHRONOS) {
                if (test.name.equals(cref.name)) {
                    CHRONOS.remove(test);
                    break;
                }
            }
        }

    }
1346392
@Transactional
    public void delete(E entity) {
        if (entityManager.contains(entity)) {
            entityManager.remove(entity);
        } else {
            // could be a delete on a transient instance
            E entityRef = entityManager.getReference(type, entity.getId());

            if (entityRef != null) {
                entityManager.remove(entityRef);
            } else {
                log.warning("Attempt to delete an instance that is not present in the database: " + entity);
            }
        }
    }
22114
def terminate(instance_id=None, name=None, region=None,
              key=None, keyid=None, profile=None, filters=None):
    '''
    
    '''
    instances = find_instances(instance_id=instance_id, name=name,
                               region=region, key=key, keyid=keyid,
                               profile=profile, return_objs=True,
                               filters=filters)
    if instances in (False, None, []):
        return instances

    if len(instances) == 1:
        instances[0].terminate()
        return True
    else:
        log.warning('Refusing to terminate multiple instances at once')
        return False