feathersdk.robot.instance_lock Module

exception feathersdk.robot.instance_lock.InstanceLockError

Bases: Exception

Base class for all instance lock errors.

feathersdk.robot.instance_lock.get_robot_instance_lock(override_lock=False, strict=True, timeout=1.0, sigterm_timeout=2.0)

Get the lock for the robot instance.

Ensures that only one instance of the robot is running at a time. Does this by creating a file lock in the /feathersys/user_config directory. Lock file is named “.robot_instance.lock”, and obtaining the lock allows a process to interact with the PID_FILE_PATH file which contains the PID of the running instance.

If the pid file exists but the process is not running, the pid file will be removed and we will write our own PID to it. If the process is still running, we will raise an error (unless override_lock is True, in which case we will kill the previous instance then write our own PID to the pid file).

NOTE: You will require correct permissions to kill the previous instance. Either sudo, or the current user must have permissions to kill the previous instance.

Parameters:
  • override_lock (bool) – If True, will override the lock, killing the previous instance and allowing a new one to run. If False, will raise an error if the previous instance is still running.

  • strict (bool) – If True, will raise an error if we attempt to acquire the lock while we already have it. Otherwise, doing so would succeed quietly.

  • timeout (float) – The timeout in seconds to wait for the file lock to be acquired.

  • sigterm_timeout (float) – The timeout in seconds to wait for the previous instance to exit after sending a SIGTERM.

Return type:

None

feathersdk.robot.instance_lock.release_robot_instance_lock(allow_no_lock=False, timeout=1.0)

Release the robot instance lock

Parameters:
  • allow_no_lock (bool) – If True, will not raise an error if we don’t have the lock.

  • timeout (float) – The timeout in seconds to wait for the file lock to be acquired.

Return type:

None

feathersdk.robot.instance_lock.is_robot_instance_locked()

Check if the robot instance lock is held by the current process

Return type:

bool

feathersdk.robot.instance_lock.check_still_own_lock()

Check if the current process still owns the lock

Return type:

bool