cheesy global lock

This commit is contained in:
Chris Meyers
2016-09-22 17:54:27 -04:00
parent 04f69727f2
commit 3a8033dec4

View File

@@ -241,8 +241,9 @@ def process_graph(graph, task_capacity):
(str(node_obj), str(impact), str(remaining_volume))) (str(node_obj), str(impact), str(remaining_volume)))
def schedule(): def schedule():
lockfile = open("/tmp/tower_scheduler.lock", "w") with transaction.atomic():
fcntl.lockf(lockfile, fcntl.LOCK_EX) # Lock
Instance.objects.select_for_update().all()[0]
task_capacity = get_system_task_capacity() task_capacity = get_system_task_capacity()
@@ -254,5 +255,4 @@ def schedule():
if graph: if graph:
process_graph(graph, task_capacity) process_graph(graph, task_capacity)
fcntl.lockf(lockfile, fcntl.LOCK_UN) # Unlock, due to transaction ending