[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH maposmatic 5/9] Merge the StandaloneMapOSMaticDa
From: |
Maxime Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH maposmatic 5/9] Merge the StandaloneMapOSMaticDaemon into the base MapOSMaticDaemon class |
Date: |
Sun, 24 Jan 2010 14:43:19 +0100 |
---
scripts/daemon.py | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/scripts/daemon.py b/scripts/daemon.py
index cfaab93..bddc7ff 100755
--- a/scripts/daemon.py
+++ b/scripts/daemon.py
@@ -40,8 +40,9 @@ RESULT_CANCELED = 'rendering took too long, canceled'
class MapOSMaticDaemon:
"""
- This is a no-op rendering daemon, base class for the different
- implementations of rendering scheduling.
+ This is a basic rendering daemon, base class for the different
+ implementations of rendering scheduling. By default, it acts as a
+ standalone, single-process MapOSMatic rendering daemon.
"""
def __init__(self, frequency):
@@ -73,25 +74,19 @@ class MapOSMaticDaemon:
LOG.info("MapOSMatic rendering daemon terminating.")
def dispatch(self, job):
- raise NotImplementedError
+ """Dispatch the given job. In this simple single-process daemon, this
+ is as simple as rendering it."""
+ self.render(job)
def render(self, job):
- raise NotImplementedError
+ """Render the given job, handling the different rendering outcomes
+ (success or failures)."""
-class StandaloneMapOSMaticDaemon(MapOSMaticDaemon):
- """
- A simple, serial, single-process standalone MapOSMatic rendering daemon.
- """
-
- def __init__(self, frequency):
- MapOSMaticDaemon.__init__(self, frequency)
-
- def dispatch(self, job):
LOG.info("Rendering job #%d '%s'..." %
(job.id, job.maptitle))
job.start_rendering()
- ret = self.render(job)
+ ret = render.render_job(job)
if ret == 0:
msg = RESULT_SUCCESSFULL
LOG.info("Finished rendering of job #%d." % job.id)
@@ -105,15 +100,17 @@ class StandaloneMapOSMaticDaemon(MapOSMaticDaemon):
job.end_rendering(msg)
- def render(self, job):
- return render.render_job(job)
-
-class ForkingMapOSMaticDaemon(MapOSMaticDaemon):
+class SubprocessMapOSMaticDaemon(MapOSMaticDaemon):
"""
- A forking, subprocess-based implementation of the MapOSMatic rendering
+ A spawning, subprocess-based implementation of the MapOSMatic rendering
daemon. Each job is handled by a subprocess from render.py.
"""
+ def __init__(self, frequency, max_process=4):
+ MapOSMaticDaemon.__init__(self, frequency)
+ self.max_process = max_process
+ self.n_process = 0
+
def dispatch(self, job):
LOG.info("Forking to render job #%d '%s'..." %
(job.id, job.maptitle))
@@ -240,7 +237,7 @@ if __name__ == '__main__':
"Please use a valid RENDERING_RESULT_PATH.")
sys.exit(1)
- daemon = StandaloneMapOSMaticDaemon(10)
+ daemon = MapOSMaticDaemon(10)
cleaner = RenderingsGarbageCollector(20)
cleaner.start()
--
1.6.3.3.277.g88938c
- [Maposmatic-dev] MapOSMatic daemon rewrite, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 1/9] Improve the file cleanup mechanism, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 2/9] Cornerstones for a new MapOSMatic daemon, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 3/9] Update the .gitignore list, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 4/9] Add MAPOSMATIC_LOG_LEVEL to the environment wrapping, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 5/9] Merge the StandaloneMapOSMaticDaemon into the base MapOSMaticDaemon class,
Maxime Petazzoni <=
- [Maposmatic-dev] [PATCH maposmatic 6/9] Revamp the job renderer, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 7/9] Rework the daemon to use the new JobRenderers, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 8/9] Frequency parameters passing improvement, Maxime Petazzoni, 2010/01/24
- [Maposmatic-dev] [PATCH maposmatic 9/9] Provide a map_areas prefix to the TimingOutJobRenderer, Maxime Petazzoni, 2010/01/24