Author: dmeyer
Date: Thu Aug 17 18:56:50 2006
New Revision: 1889
Modified:
trunk/beacon/src/parser.py
trunk/beacon/src/thumbnail/__init__.py
trunk/beacon/src/thumbnail/server.py
trunk/beacon/src/thumbnail/thumbnail.py
Log:
better thumbnail priority handling
Modified: trunk/beacon/src/parser.py
==============================================================================
--- trunk/beacon/src/parser.py (original)
+++ trunk/beacon/src/parser.py Thu Aug 17 18:56:50 2006
@@ -204,7 +204,7 @@
if attributes.get('image'):
t = thumbnail.Thumbnail(attributes.get('image'), item._beacon_media)
if not t.get(thumbnail.LARGE, check_mtime=True):
- t.create(thumbnail.LARGE)
+ t.create(thumbnail.LARGE, thumbnail.PRIORITY_LOW)
if not metadata.get('title'):
# try to set a good title
Modified: trunk/beacon/src/thumbnail/__init__.py
==============================================================================
--- trunk/beacon/src/thumbnail/__init__.py (original)
+++ trunk/beacon/src/thumbnail/__init__.py Thu Aug 17 18:56:50 2006
@@ -1,5 +1,6 @@
import os
-from thumbnail import Thumbnail, NORMAL, LARGE, connect
+from thumbnail import Thumbnail, NORMAL, LARGE, connect, \
+ PRIORITY_HIGH, PRIORITY_NORMAL, PRIORITY_LOW
support_video = False
for path in os.environ.get('PATH').split(':'):
Modified: trunk/beacon/src/thumbnail/server.py
==============================================================================
--- trunk/beacon/src/thumbnail/server.py (original)
+++ trunk/beacon/src/thumbnail/server.py Thu Aug 17 18:56:50 2006
@@ -49,20 +49,18 @@
# get logging object
log = logging.getLogger('beacon.thumbnail')
-PRIORITY_HIGH, PRIORITY_LOW = range(2)
-
THUMBNAIL_TIMER = 0.1
class Job(object):
"""
A job with thumbnail information.
"""
- def __init__(self, id, filename, imagefile, size):
+ def __init__(self, id, filename, imagefile, size, priority):
self.client, self.id = id
self.filename = filename
self.imagefile = imagefile
self.size = size
- self.priority = PRIORITY_HIGH
+ self.priority = priority
class Thumbnailer(object):
@@ -217,19 +215,18 @@
# -------------------------------------------------------------------------
@kaa.rpc.expose('schedule')
- def schedule(self, id, filename, imagefile, size):
- self.jobs.append(Job(id, filename, imagefile, size))
+ def schedule(self, id, filename, imagefile, size, priority):
+ self.jobs.append(Job(id, filename, imagefile, size, priority))
self._activate(THUMBNAIL_TIMER)
- @kaa.rpc.expose('reduce_priority')
- def reduce_priority(self, id):
+ @kaa.rpc.expose('set_priority')
+ def set_priority(self, id, priority):
for schedule in self.jobs, self.videothumb.jobs:
for job in schedule:
if id != (job.client, job.id):
continue
- log.info('reduce priority %s' % job.id)
- job.priority = PRIORITY_LOW
+ job.priority = priority
schedule.sort(lambda x,y: cmp(x.priority, y.priority))
return
Modified: trunk/beacon/src/thumbnail/thumbnail.py
==============================================================================
--- trunk/beacon/src/thumbnail/thumbnail.py (original)
+++ trunk/beacon/src/thumbnail/thumbnail.py Thu Aug 17 18:56:50 2006
@@ -34,6 +34,10 @@
NORMAL = 'normal'
LARGE = 'large'
+PRIORITY_HIGH = 0
+PRIORITY_NORMAL = 1
+PRIORITY_LOW = 2
+
# python imports
import os
import md5
@@ -62,9 +66,10 @@
all = []
- def __init__(self, job, id):
+ def __init__(self, job, id, priority):
self.valid = weakref(job)
self.id = id
+ self.priority = priority
self.signal = kaa.notifier.Signal()
Job.all.append(self)
@@ -137,7 +142,7 @@
return self.get('fail/kaa')
- def create(self, type=NORMAL):
+ def create(self, type=NORMAL, priority=PRIORITY_NORMAL):
Thumbnail.next_id += 1
dest = '%s/%s' % (self.destdir, type)
@@ -146,9 +151,9 @@
# schedule thumbnail creation
_client.schedule(Thumbnail.next_id, self.name,
- self._thumbnail % type, SIZE[type])
+ self._thumbnail % type, SIZE[type], priority)
- job = Job(self, Thumbnail.next_id)
+ job = Job(self, Thumbnail.next_id, priority)
return job.signal
@@ -167,14 +172,14 @@
self.rpc = server.rpc
- def schedule(self, id, filename, imagename, type):
+ def schedule(self, id, filename, imagename, type, priority):
if not self.id:
# Not connected yet, schedule job later
- self._schedules.append((id, filename, imagename, type))
+ self._schedules.append((id, filename, imagename, type, priority))
return
# server rpc calls
- self.rpc('schedule', (self.id, id), filename, imagename, type)
+ self.rpc('schedule', (self.id, id), filename, imagename, type,
priority)
@kaa.rpc.expose('connect')
@@ -203,7 +208,8 @@
continue
# set old jobs to lower priority
Job.all.remove(job)
- self.rpc('reduce_priority', (self.id, job.id))
+ if job.priority != PRIORITY_LOW:
+ self.rpc('set_priority', (self.id, job.id), PRIORITY_LOW)
def connect():
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog