Changeset cf0d7e8 for server/lib/gutenbach/server/printer.py
- Timestamp:
- Jan 21, 2012, 3:18:41 PM (12 years ago)
- Branches:
- no-cups
- Children:
- cb0195f
- Parents:
- d17381b
- git-author:
- Steven Allen <steven@…> (01/21/12 15:18:41)
- git-committer:
- Steven Allen <steven@…> (01/21/12 15:18:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/printer.py
r609a9b0 rcf0d7e8 9 9 import traceback 10 10 import sys 11 from . import sync 11 12 12 13 … … 124 125 125 126 @property 127 @sync 126 128 def state(self): 127 with self.lock: 128 if self.current_job is not None: 129 val = States.PROCESSING 130 elif len(self.pending_jobs) == 0: 131 val = States.IDLE 132 else: 133 val = States.STOPPED 134 return val 135 136 @property 129 if self.current_job is not None: 130 return States.PROCESSING 131 elif len(self.pending_jobs) == 0: 132 return States.IDLE 133 else: 134 return States.STOPPED 135 136 @property 137 @sync 137 138 def active_jobs(self): 138 with self.lock: 139 jobs = self.pending_jobs[:] 140 if self.current_job is not None: 141 jobs.insert(0, self.current_job.id) 139 jobs = self.pending_jobs[:] 140 if self.current_job is not None: 141 jobs.insert(0, self.current_job.id) 142 142 return jobs 143 143 … … 146 146 ###################################################################### 147 147 148 @sync 148 149 def start_job(self): 149 with self.lock: 150 if self.current_job is None: 151 try: 152 job_id = heapq.heappop(self.pending_jobs) 153 self.current_job = self.get_job(job_id) 154 self.current_job.play() 155 except IndexError: 156 self.current_job = None 157 except InvalidJobStateException: 158 heapq.heappush(self.pending_jobs, self.current_job.id) 159 self.current_job = None 150 if self.current_job is None: 151 try: 152 job_id = heapq.heappop(self.pending_jobs) 153 self.current_job = self.get_job(job_id) 154 self.current_job.play() 155 except IndexError: 156 self.current_job = None 157 except InvalidJobStateException: 158 heapq.heappush(self.pending_jobs, self.current_job.id) 159 self.current_job = None 160 160 161 @sync 161 162 def complete_job(self): 162 with self.lock:163 if self.current_job is None:164 return 165 166 try:167 if not self.current_job.is_done:168 self.current_job.stop()169 finally:170 self.finished_jobs.append(self.current_job.id)171 self.current_job = None 172 163 if self.current_job is None: 164 return 165 166 try: 167 if not self.current_job.is_done: 168 self.current_job.stop() 169 finally: 170 self.finished_jobs.append(self.current_job.id) 171 self.current_job = None 172 173 @sync 173 174 def get_job(self, job_id): 174 with self.lock: 175 if job_id not in self.jobs: 176 raise InvalidJobException(job_id) 177 job = self.jobs[job_id] 178 return job 175 if job_id not in self.jobs: 176 raise InvalidJobException(job_id) 177 return self.jobs[job_id] 179 178 180 179 ######################################################################
Note: See TracChangeset
for help on using the changeset viewer.