Skip to content

Commit a987c94

Browse files
author
Matt George
committed
first stab at proctitle
1 parent 001f614 commit a987c94

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

pyres/worker.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from pyres.exceptions import NoQueueError
22
from pyres.job import Job
3-
from pyres import ResQ, Stat
3+
from pyres import ResQ, Stat, __version__
44
import logging
55
import signal
66
import datetime, time
77
import os, sys
88
import time
99
import json_parser as json
1010
import commands
11+
try:
12+
from setproctitle import setproctitle
13+
except:
14+
def setproctitle(name):
15+
pass
1116

1217
class Worker(object):
1318
"""Defines a worker. The ``pyres_worker`` script instantiates this Worker class and
@@ -118,6 +123,7 @@ def work(self, interval=5):
118123
Finally, the ``process`` method actually processes the job by eventually calling the Job instance's ``perform`` method.
119124
120125
"""
126+
setproctitle('pyres: Starting')
121127
self.startup()
122128
while True:
123129
if self._shutdown:
@@ -129,6 +135,7 @@ def work(self, interval=5):
129135
logging.debug('job details: %s' % job)
130136
self.child = os.fork()
131137
if self.child:
138+
setproctitle("pyres-%s: Forked %s at %s" % (__version__, self.child, datetime.datetime.now()))
132139
logging.info('Forked %s at %s' % (self.child, datetime.datetime.now()))
133140
try:
134141
os.waitpid(self.child, 0)
@@ -139,13 +146,16 @@ def work(self, interval=5):
139146
#os.wait()
140147
logging.debug('done waiting')
141148
else:
149+
setproctitle("pyres-%s: Processing %s since %s" % (__version__, job._queue, datetime.datetime.now()))
142150
logging.info('Processing %s since %s' % (job._queue, datetime.datetime.now()))
143151
self.process(job)
144152
os._exit(0)
145153
self.child = None
146154
else:
147155
if interval == 0:
148156
break
157+
#procline @paused ? "Paused" : "Waiting for #{@queues.join(',')}"
158+
setproctitle("pyres-%s: Waiting for %s " % (__version__, ','.join(self.queues)))
149159
time.sleep(interval)
150160
self.unregister_worker()
151161

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
simplejson==2.0.9
22
itty==0.6.2
33
redis==1.34.1
4-
pystache==0.1.0
4+
pystache==0.1.0
5+
setproctitle==1.0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
'simplejson>=2.0.9',
2020
'itty>=0.6.2',
2121
'redis==1.34.1',
22-
'pystache>=0.1.0'
22+
'pystache>=0.1.0',
23+
'setproctitle==1.0'
2324
],
2425
classifiers = [
2526
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)