Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
f4d2e5af
Commit
f4d2e5af
authored
14 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
added JobManager logging to syslog
parent
cc3b071c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ccnode/jobs.py
+8
-3
8 additions, 3 deletions
ccnode/jobs.py
with
8 additions
and
3 deletions
ccnode/jobs.py
+
8
−
3
View file @
f4d2e5af
...
@@ -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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment