import os, re
import bb.utils
+# This is the pid for which we should generate the event. This is set when
+# the runqueue forks off.
+worker_pid = 0
+
class Event:
"""Base class for events"""
type = "Event"
def __init__(self, d):
self._data = d
+ self.pid = worker_pid
def getData(self):
return self._data
self.stats.taskSkipped()
continue
- bb.event.fire(runQueueTaskStarted(task, self.stats, self, self.cfgData))
- bb.msg.note(1, bb.msg.domain.RunQueue, "Running task %d of %d (ID: %s, %s)" % (self.stats.completed + self.stats.active + 1, self.stats.total, task, self.get_user_idstring(task)))
sys.stdout.flush()
sys.stderr.flush()
try:
except OSError, e:
bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
if pid == 0:
+ # Save out the PID so that the event can include it the
+ # events
+ bb.event.worker_pid = os.getpid()
+
+ bb.event.fire(runQueueTaskStarted(task, self.stats, self, self.cfgData))
+ bb.msg.note(1, bb.msg.domain.RunQueue,
+ "Running task %d of %d (ID: %s, %s)" % (self.stats.completed + self.stats.active + 1,
+ self.stats.total,
+ task,
+ self.get_user_idstring(task)))
self.state = runQueueChildProcess
# Make the child the process group leader
os.setpgid(0, 0)