get suitable job
(self, occ)
| 293 | #---------------------------------------------------------------------- |
| 294 | @lock |
| 295 | def getJob(self, occ): |
| 296 | """get suitable job""" |
| 297 | |
| 298 | #@TODO clean mess |
| 299 | #@TODO improve selection of valid jobs |
| 300 | |
| 301 | if occ in self.jobCache: |
| 302 | if self.jobCache[occ]: |
| 303 | id = self.jobCache[occ].pop() |
| 304 | if id == "empty": |
| 305 | pyfile = None |
| 306 | self.jobCache[occ].append("empty") |
| 307 | else: |
| 308 | pyfile = self.getFile(id) |
| 309 | else: |
| 310 | jobs = self.db.getJob(occ) |
| 311 | jobs.reverse() |
| 312 | if not jobs: |
| 313 | self.jobCache[occ].append("empty") |
| 314 | pyfile = None |
| 315 | else: |
| 316 | self.jobCache[occ].extend(jobs) |
| 317 | pyfile = self.getFile(self.jobCache[occ].pop()) |
| 318 | |
| 319 | else: |
| 320 | self.jobCache = {} #better not caching to much |
| 321 | jobs = self.db.getJob(occ) |
| 322 | jobs.reverse() |
| 323 | self.jobCache[occ] = jobs |
| 324 | |
| 325 | if not jobs: |
| 326 | self.jobCache[occ].append("empty") |
| 327 | pyfile = None |
| 328 | else: |
| 329 | pyfile = self.getFile(self.jobCache[occ].pop()) |
| 330 | |
| 331 | #@TODO: maybe the new job has to be approved... |
| 332 | |
| 333 | |
| 334 | #pyfile = self.getFile(self.jobCache[occ].pop()) |
| 335 | return pyfile |
| 336 | |
| 337 | @lock |
| 338 | def getDecryptJob(self): |