You are here

function background_process_lock_process in Background Process 7

Same name and namespace in other branches
  1. 8 background_process.module \background_process_lock_process()
  2. 6 background_process.module \background_process_lock_process()

Lock process.

Parameters

string $handle: Handle of background process

Return value

bool TRUE if locked, FALSE if lock could not be obtained

1 call to background_process_lock_process()
BackgroundProcess::lock in ./BackgroundProcess.class.php

File

./background_process.module, line 737

Code

function background_process_lock_process($handle, $status = BACKGROUND_PROCESS_STATUS_LOCKED) {
  try {
    $old_db = db_set_active('background_process');
    db_insert('background_process')
      ->fields(array(
      'handle' => $handle,
      'start_stamp' => sprintf("%.06f", microtime(TRUE)),
      'exec_status' => $status,
    ))
      ->execute();
    db_set_active($old_db);
    _background_process_ensure_cleanup($handle);
    return TRUE;
  } catch (Exception $e) {
    db_set_active($old_db);
    return FALSE;
  }
}