Evaluate an expression as a background job (uses a separate thread).
| 443 | |
| 444 | |
| 445 | class BackgroundJobExpr(BackgroundJobBase): |
| 446 | """Evaluate an expression as a background job (uses a separate thread).""" |
| 447 | |
| 448 | def __init__(self, expression, glob=None, loc=None): |
| 449 | """Create a new job from a string which can be fed to eval(). |
| 450 | |
| 451 | global/locals dicts can be provided, which will be passed to the eval |
| 452 | call.""" |
| 453 | |
| 454 | # fail immediately if the given expression can't be compiled |
| 455 | self.code = compile(expression,'<BackgroundJob compilation>','eval') |
| 456 | |
| 457 | glob = {} if glob is None else glob |
| 458 | loc = {} if loc is None else loc |
| 459 | self.expression = self.strform = expression |
| 460 | self.glob = glob |
| 461 | self.loc = loc |
| 462 | self._init() |
| 463 | |
| 464 | def call(self): |
| 465 | return eval(self.code,self.glob,self.loc) |
| 466 | |
| 467 | |
| 468 | class BackgroundJobFunc(BackgroundJobBase): |
no outgoing calls
no test coverage detected
searching dependent graphs…