class_docstr: Legacy protocol, store all experiments and trials inside the Database()
  
  Parameters
  ----------
  config: Dict
      configuration definition passed from experiment_builder
      to storage factory to legacy constructor.
      See `~orion.io.database.Database` for more details
  setup: bool
      Setup the database (create indexes)
class_docstr_tok: ["Legacy","protocol",",","store","all","experiments","and","trials","inside","the","Database","(",")","Parameters","--","--","--","--","--","config",":","Dict","configuration","definition","passed","from","experiment_builder","to","storage","factory","to","legacy","constructor",".","See","`","~orion.io.database.Database","`","for","more","details","setup",":","bool","Setup","the","database","(","create","indexes",")"]
docstr: See :func:`orion.storage.base.BaseStorageProtocol.acquire_algorithm_lock`
docstr_tok: ["See",":","func",":","`","orion.storage.base.BaseStorageProtocol.acquire_algorithm_lock","`"]
code: def acquire_algorithm_lock(
      self, experiment=None, uid=None, timeout=60, retry_interval=1
  ):
      """See :func:`orion.storage.base.BaseStorageProtocol.acquire_algorithm_lock`"""
      uid = get_uid(experiment, uid)
  
      algo_state_lock = None
      start = time.perf_counter()
      while (
          algo_state_lock is None
          and time.perf_counter() - start < timeout
      ):
          algo_state_lock = self._db.read_and_write(
              "algo",
              query=dict(experiment=uid, locked=0),
              data=dict(
                  locked=1,
                  heartbeat=datetime.datetime.utcnow(),
              ),
          )
          if algo_state_lock is None:
              time.sleep(retry_interval)
  
      if algo_state_lock is None:
          raise LockAcquisitionTimeout
  
      locked_algo_state = LockedAlgorithmState(
          state=pickle.loads(algo_state_lock["state"])
          if algo_state_lock["state"] is not None
          else None,
          configuration=algo_state_lock["configuration"],
          locked=True,
      )
  
      try:
          yield locked_algo_state
      except Exception:
          # Reset algo to state fetched lock time
          locked_algo_state.reset()
          raise
      finally:
          self.release_algorithm_lock(
              uid=uid, new_state=locked_algo_state.state
          )
  
imports: import contextlib
  import datetime
  import logging
  import pickle
  import time
  import orion.core
  import orion.core.utils.backward
  from orion.core.io.database import Database, OutdatedDatabaseError, database_factory
  from orion.core.worker.trial import Trial, validate_status
  from orion.storage.base import BaseStorageProtocol, FailedUpdate, LockAcquisitionTimeout, LockedAlgorithmState, get_trial_uid_and_exp, get_uid
label_desc: Use image node_id 32 for calling the Legacy obj's underlying member method code with example usage: obj.acquire_algorithm_lock(experiment, uid, timeout, retry_interval) without return types