Skip to content
Snippets Groups Projects
Commit f4d2e5af authored by Thibault VINCENT's avatar Thibault VINCENT
Browse files

added JobManager logging to syslog

parent cc3b071c
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import os, time, socket import os, time, socket
from datetime import datetime from datetime import datetime
from threading import Thread, RLock from threading import Thread, RLock
from logging import debug
from utils import RWLock from utils import RWLock
from errors import (JobManagerError, JobError, XferJobError, ReceiveFileJobError, from errors import (JobManagerError, JobError, XferJobError, ReceiveFileJobError,
SendFileJobError) SendFileJobError)
...@@ -31,10 +32,11 @@ class JobManager(Thread, object): ...@@ -31,10 +32,11 @@ class JobManager(Thread, object):
def _job_crashed(self, jid): def _job_crashed(self, jid):
''' '''
''' '''
debug('JobManager._job_crashed: id=`%i`' % jid)
with self._mutex: with self._mutex:
# job should exist # job should exist
if jid not in self._jobs: if jid not in self._jobs:
raise JobManagerError('unknown job ID `%i`' % jid) raise JobManagerError('unknown job ID `%i`', jid)
# move job to the crashed queue # move job to the crashed queue
self._jobs_crashed.append(jid) self._jobs_crashed.append(jid)
# clean any queue that may contain the job # clean any queue that may contain the job
...@@ -44,10 +46,11 @@ class JobManager(Thread, object): ...@@ -44,10 +46,11 @@ class JobManager(Thread, object):
queue.remove(jid) queue.remove(jid)
def _job_finished(self, jid): def _job_finished(self, jid):
debug('JobManager._job_finished: id=`%i`' % jid)
with self._mutex: with self._mutex:
# job should exist # job should exist
if jid not in self._jobs: if jid not in self._jobs:
raise JobManagerError('unknown job ID `%i`' % jid) raise JobManagerError('unknown job ID `%i`', jid)
# move job to the finished queue # move job to the finished queue
self._jobs_finished.append(jid) self._jobs_finished.append(jid)
# remove from running queue # remove from running queue
...@@ -61,6 +64,7 @@ class JobManager(Thread, object): ...@@ -61,6 +64,7 @@ class JobManager(Thread, object):
self._next_jid += 1 self._next_jid += 1
self._jobs[jid] = job self._jobs[jid] = job
self._jobs_pending.append(jid) self._jobs_pending.append(jid)
debug('JobManager.append: new job pending with id `%i`', jid)
return jid return jid
def run(self): def run(self):
...@@ -72,6 +76,7 @@ class JobManager(Thread, object): ...@@ -72,6 +76,7 @@ class JobManager(Thread, object):
def schedule_immediate(self, jid): def schedule_immediate(self, jid):
''' '''
''' '''
debug('JobManager.schedule_immediate: id=`%i`', jid)
with self._mutex: with self._mutex:
# job should exist # job should exist
if jid not in self._jobs: if jid not in self._jobs:
...@@ -138,7 +143,7 @@ class JobLog(): ...@@ -138,7 +143,7 @@ class JobLog():
def append(self, message): def append(self, message):
''' '''
''' '''
print "JobLog : %s" % message debug('JobLog.append: %s', message)
with self._mutex: with self._mutex:
self._items.append((time.time(), message)) self._items.append((time.time(), message))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment