diff options
author | Dan McGee <dan@archlinux.org> | 2011-11-17 10:17:55 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-11-17 10:17:55 -0600 |
commit | 9d2fdbe5bc6a0d9ab2907b377056851fc5eb56c3 (patch) | |
tree | 45c3ebe0d676cd1f3b7a2ed1c6755d27c77bee8b /devel/management | |
parent | aa20c798ca8af365b2549591700e932a74d068b8 (diff) |
reporead_inotify: nice the spawned subprocesses
This prevents the reporead job from taking over time from more important
processes; this is not a rush task.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/management')
-rwxr-xr-x | devel/management/commands/reporead_inotify.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/devel/management/commands/reporead_inotify.py b/devel/management/commands/reporead_inotify.py index acb53a54..c74762eb 100755 --- a/devel/management/commands/reporead_inotify.py +++ b/devel/management/commands/reporead_inotify.py @@ -16,7 +16,7 @@ correctly. import logging import multiprocessing -import os.path +import os import pyinotify import sys import threading @@ -113,10 +113,11 @@ class Database(object): various bits of metadata and state representing the file path, when we last updated, how long our delay is before performing the update, whether we are updating now, etc.''' - def __init__(self, arch, path, delay=60.0): + def __init__(self, arch, path, delay=60.0, nice=3): self.arch = arch self.path = path self.delay = delay + self.nice = nice self.mtime = None self.last_import = None self.update_thread = None @@ -153,8 +154,12 @@ class Database(object): # invoke reporead's primary method. we do this in a separate # process for memory conservation purposes; these processes grow # rather large so it is best to free up the memory ASAP. - process = multiprocessing.Process(target=read_repo, - args=[self.arch, self.path, {}]) + def run(): + if self.nice != 0: + os.nice(self.nice) + read_repo(self.arch, self.path, {}) + + process = multiprocessing.Process(target=run) process.start() process.join() finally: |