model_lock: Model lock/unlock

Description Usage Arguments Value Author(s) See Also Examples

View source: R/model_lock.R

Description

Functions that indicate whether a model folder is currently locked by another process or not. This helps to prevent unintended interactions between processes.

Usage

1
2
3
model_lock(folder=".", file=".lock", timeout1=NULL, timeout2=NULL,
check_interval=1, oncluster=TRUE)
model_unlock(id,folder=".",file=".lock",oncluster=TRUE)

Arguments

folder

model folder

file

file name of the lock file containing the process queue

timeout1

Time in hours the top process in the queue is allowed to run before the current process is stopped.

timeout2

Time in hours the processed is allowed to wait in the queue before it is stopped

check_interval

Time in seconds between checking the current position in the queue.

oncluster

a logical indicating whether the script is run on cluster or not. On windows a lock file is created, which does not prevent simulatneous access to the model. On the cluster the system command 'mkdir' is used to prevent simultaneous access. This atomicity of check-and-create is ensured at the operating system kernel level.

id

process id as returned by model_lock.

Value

model_lock returns the process id which is needed (only on Windows) to identify the process in model_unlock.

Author(s)

Jan Philipp Dietrich, David Klein

See Also

check_config

Examples

1
2
3
4
5
#lock folder
id <- model_lock(tempdir())

#unlock folder
model_unlock(id,tempdir())

gms documentation built on July 2, 2020, 2:36 a.m.