Skip to content

Commit feaaa7a

Browse files
mjrussoMatt George
authored andcommitted
bug fix for worker_pids method. the "ps -A -o pid,command" command includes leading whitespace before the pid if the pid is below a certain threshold, and this behavior was causing workers to be pruned prematurely. we now compensate for this leading whitespace
1 parent 6714883 commit feaaa7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pyres/worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ def job(self):
217217
def processing(self):
218218
return self.job()
219219

220-
def state(self):
220+
def state(self):.
221221
return 'working' if self.resq.redis.exists('resque:worker:%s' % self) else 'idle'
222222

223223
def worker_pids(self):
224224
"""Returns an array of all pids (as strings) of the workers on
225225
this machine. Used when pruning dead workers."""
226-
return map(lambda l: l.split(' ')[0],
226+
return map(lambda l: l.strip().split(' ')[0],
227227
commands.getoutput("ps -A -o pid,command | \
228228
grep pyres_worker").split("\n"))
229229

0 commit comments

Comments
 (0)