Changeset d42236e for server/lib/gutenbach/server/printer.py
- Timestamp:
- Jan 21, 2012, 11:14:07 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 75928fe
- Parents:
- 3cb6c7b
- git-author:
- Jessica B. Hamrick <jhamrick@…> (01/21/12 23:12:03)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (01/21/12 23:14:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/printer.py
r7e29e6a rd42236e 6 6 import time 7 7 import threading 8 import heapq9 8 import traceback 10 9 import sys … … 102 101 self._running = True 103 102 while self._running: 104 try:105 with self.lock:103 with self.lock: 104 try: 106 105 if self.current_job is None: 107 106 self.start_job() 108 107 elif self.current_job.is_done: 109 108 self.complete_job() 110 except: 111 logger.fatal(traceback.format_exc()) 112 sys.exit(1) 109 except: 110 self._running = False 111 logger.fatal(traceback.format_exc()) 112 break 113 113 time.sleep(0.1) 114 114 115 115 def stop(self): 116 116 with self.lock: 117 for job in self.jobs.keys(): 118 try: 119 self.jobs[job].abort() 120 del self.jobs[job] 121 except InvalidJobStateException: 122 pass 123 117 124 self._running = False 118 125 if self.ident is not None and self.isAlive(): … … 159 166 @sync 160 167 def state(self): 161 if self.is_running and self.current_job is not None: 162 state = States.PROCESSING 163 elif self.is_running and len(self.pending_jobs) == 0: 164 state = States.IDLE 168 if self.is_running and not self.paused: 169 if len(self.active_jobs) > 0: 170 state = States.PROCESSING 171 else: 172 state = States.IDLE 165 173 else: 166 174 state = States.STOPPED 175 167 176 return state 168 177 … … 194 203 if not self.paused and self.current_job is None: 195 204 try: 196 job_id = heapq.heappop(self.pending_jobs)205 job_id = self.pending_jobs.pop(0) 197 206 self.current_job = self.get_job(job_id) 198 207 self.current_job.play() 199 208 except IndexError: 200 self.current_job = None201 except InvalidJobStateException:202 heapq.heappush(self.pending_jobs, self.current_job.id)203 209 self.current_job = None 204 210 … … 530 536 531 537 @sync 532 def create_job(self, requesting_user_name=None, job_name=None,533 job_ k_octets=None):538 def create_job(self, requesting_user_name=None, 539 job_name=None, job_k_octets=None): 534 540 535 541 self.assert_running() … … 544 550 545 551 self.jobs[job_id] = job 546 self.pending_jobs.append(job_id)547 548 552 return job_id 549 553 … … 617 621 job = self.get_job(job_id) 618 622 job.spool(document) 619 623 if 'dryrun' in self.config and self.config['dryrun']: 624 job.player._dryrun = True 625 self.pending_jobs.append(job_id) 626 620 627 @sync 621 628 def send_uri(self, job_id, document_uri, document_name=None, … … 628 635 # XXX: need to validate URI 629 636 # XXX: need to deal with the URI stream? 637 630 638 #job.spool_uri(document_uri) 631 639 #if 'dryrun' in self.config and self.config['dryrun']: 640 # job.player._dryrun = True 641 #self.pending_jobs.append(job_id) 642 632 643 @sync 633 644 def get_job_attributes(self, job_id, requested_attributes=None):
Note: See TracChangeset
for help on using the changeset viewer.