Skip to content

Commit

Permalink
fix(io/default): Make the tidy-up task exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
ketiltrout committed Aug 8, 2024
1 parent 995934d commit 2083055
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion alpenhorn/io/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# This sets how often we run the clean-up idle task. What
# we're counting here is number of not-idle -> idle transitions
_IDLE_CLEANUP_PERIOD = 100 # (i.e. once every 100 opportunities)
_IDLE_CLEANUP_PERIOD = 400 # (i.e. once every 400 opportunities)


class DefaultNodeRemote(BaseNodeRemote):
Expand Down Expand Up @@ -135,9 +135,15 @@ def _async(task, node, tree_lock):
if newly_idle:
if self._skip_idle_cleanup <= 1:
self._skip_idle_cleanup = _IDLE_CLEANUP_PERIOD

# NB: this is an exclusive task: it will remain
# queued until no other I/O is happening on this
# node, and then prevent other I/O from happening
# on the node while it's running.
Task(
func=_async,
queue=self._queue,
exclusive=True,
key=self.fifo,
args=(self.node, self.tree_lock),
name=f"Tidy up {self.node.name}",
Expand Down

0 comments on commit 2083055

Please sign in to comment.