Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Roman Karwacik
website
Commits
ddefbbfc
Unverified
Commit
ddefbbfc
authored
6 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
moved firering of job handlers to jobmanagement
parent
1d32e6d8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
jobmanagement.py
+9
-0
9 additions, 0 deletions
jobmanagement.py
jobs.py
+1
-5
1 addition, 5 deletions
jobs.py
with
10 additions
and
5 deletions
jobmanagement.py
+
9
−
0
View file @
ddefbbfc
...
...
@@ -14,6 +14,15 @@ def job_handler(*types, state='finished'):
return
func
return
wrapper
def
job_handler_handle
(
id
,
state
):
job
=
query
(
'
SELECT * FROM jobs WHERE id = ?
'
,
id
,
nlfix
=
False
)[
0
]
type
=
job
[
'
type
'
]
for
func
in
job_handlers
.
get
(
type
,
{}).
get
(
state
,
[]):
try
:
func
(
id
,
job
[
'
type
'
],
json
.
loads
(
job
[
'
data
'
]),
state
,
json
.
loads
(
job
[
'
status
'
]))
except
Exception
:
traceback
.
print_exc
()
@sched_func
(
10
)
def
job_catch_broken
():
# scheduled but never pinged
...
...
This diff is collapsed.
Click to expand it.
jobs.py
+
1
−
5
View file @
ddefbbfc
...
...
@@ -79,12 +79,8 @@ def jobs_ping(id):
query
(
'
UPDATE jobs SET time_finished = ?, status = ?, state =
"
finished
"
where id = ?
'
,
datetime
.
now
(),
status
,
id
)
else
:
query
(
'
UPDATE jobs SET worker = ?, last_ping = ?, status = ?, state = ? where id = ?
'
,
hostname
,
datetime
.
now
(),
status
,
state
,
id
)
job_handler_handle
(
id
,
state
)
job
=
query
(
'
SELECT * FROM jobs WHERE id = ?
'
,
id
,
nlfix
=
False
)[
0
]
for
func
in
job_handlers
.
get
(
job
[
'
type
'
],
{}).
get
(
state
,
[]):
try
:
func
(
id
,
job
[
'
type
'
],
json
.
loads
(
job
[
'
data
'
]),
state
,
json
.
loads
(
job
[
'
status
'
]))
except
Exception
:
traceback
.
print_exc
()
if
job
[
'
canceled
'
]:
return
'
Job canceled
'
,
205
else
:
...
...
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