diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-02-26 11:32:25 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-02-26 11:32:25 +0100 |
| commit | bcaee98d6db7d24df8ccd25bc466ca6da3b4f75e (patch) | |
| tree | 2904139a546da966e9848eeec253bd67fa052514 /joblib.py | |
| parent | fa1932a5ac4dd16c743ae55315aa7419297058b1 (diff) | |
| download | joblib-bcaee98d6db7d24df8ccd25bc466ca6da3b4f75e.tar.gz joblib-bcaee98d6db7d24df8ccd25bc466ca6da3b4f75e.zip | |
acquire: return priority
Diffstat (limited to 'joblib.py')
| -rw-r--r-- | joblib.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -36,15 +36,15 @@ class JobQueue(object): """, jobtype, json.dumps(payload), priority) async def acquire(self, jobtype): - """Mark a job as running, return payload and return id. - Return (None, None) if no job is available.""" + """Mark a job as running, return id, payload and priority. + Return (None, None, None) if no job is available.""" async with self._pool.acquire() as con: while True: try: # do not allow async access async with con.transaction(isolation="serializable"): result = await con.fetchrow(""" - SELECT id, payload + SELECT id, payload, priority FROM jobs WHERE type=$1 AND status='open' ORDER BY priority DESC @@ -52,13 +52,13 @@ class JobQueue(object): if result is None: # no jobs available return None, None - jobid, payload = result + jobid, payload, priority = result await con.execute(""" UPDATE jobs SET status='running' WHERE id=$1 """, jobid) - return jobid, json.loads(payload) + return jobid, json.loads(payload), priority except asyncpg.exceptions.SerializationError: # job is being picked up by another worker, try again pass |
