Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
58d9c272
Commit
58d9c272
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Jobs: Některé joby mohou expirovat po delší době
parent
57d28028
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
etc/config.py.example
+3
-0
3 additions, 0 deletions
etc/config.py.example
mo/jobs/__init__.py
+5
-1
5 additions, 1 deletion
mo/jobs/__init__.py
with
8 additions
and
1 deletion
etc/config.py.example
+
3
−
0
View file @
58d9c272
...
@@ -48,6 +48,9 @@ GC_PERIOD = 60
...
@@ -48,6 +48,9 @@ GC_PERIOD = 60
# Za jak dlouho expiruje dokončená dávka [min]
# Za jak dlouho expiruje dokončená dávka [min]
JOB_EXPIRATION = 5
JOB_EXPIRATION = 5
# Některé dávky (analýza scanů) mají delší expiraci [min]
JOB_EXPIRATION_LONG = 1440
# Kolik nejvýše dovolujeme registrací za minutu
# Kolik nejvýše dovolujeme registrací za minutu
REG_MAX_PER_MINUTE = 10
REG_MAX_PER_MINUTE = 10
...
...
This diff is collapsed.
Click to expand it.
mo/jobs/__init__.py
+
5
−
1
View file @
58d9c272
...
@@ -27,6 +27,7 @@ class TheJob:
...
@@ -27,6 +27,7 @@ class TheJob:
job_id
:
Optional
[
int
]
job_id
:
Optional
[
int
]
gatekeeper
:
Optional
[
mo
.
rights
.
Gatekeeper
]
gatekeeper
:
Optional
[
mo
.
rights
.
Gatekeeper
]
errors
:
List
[
str
]
errors
:
List
[
str
]
expires_in_minutes
:
int
def
__init__
(
self
,
job_id
:
Optional
[
int
]
=
None
):
def
__init__
(
self
,
job_id
:
Optional
[
int
]
=
None
):
"""
Pokud chceme pracovat s existujícím jobem, zadáme jeho ID.
"""
"""
Pokud chceme pracovat s existujícím jobem, zadáme jeho ID.
"""
...
@@ -133,10 +134,13 @@ class TheJob:
...
@@ -133,10 +134,13 @@ class TheJob:
job
=
self
.
job
job
=
self
.
job
logger
.
info
(
f
'
Job: Spouštím job #
{
job
.
job_id
}
(
{
job
.
type
}
) uživatele #
{
job
.
user_id
}
'
)
logger
.
info
(
f
'
Job: Spouštím job #
{
job
.
job_id
}
(
{
job
.
type
}
) uživatele #
{
job
.
user_id
}
'
)
job
.
state
=
db
.
JobState
.
running
job
.
state
=
db
.
JobState
.
running
job
.
finished_at
=
None
job
.
expires_at
=
None
sess
.
commit
()
sess
.
commit
()
try
:
try
:
self
.
gatekeeper
=
mo
.
rights
.
Gatekeeper
(
job
.
user
)
self
.
gatekeeper
=
mo
.
rights
.
Gatekeeper
(
job
.
user
)
self
.
expires_in_minutes
=
config
.
JOB_EXPIRATION
_handler_table
[
job
.
type
](
self
)
_handler_table
[
job
.
type
](
self
)
if
self
.
errors
:
if
self
.
errors
:
logger
.
info
(
f
'
Job: Neúspěšně dokončen job #
{
job
.
job_id
}
(
{
job
.
result
}
)
'
)
logger
.
info
(
f
'
Job: Neúspěšně dokončen job #
{
job
.
job_id
}
(
{
job
.
result
}
)
'
)
...
@@ -153,7 +157,7 @@ class TheJob:
...
@@ -153,7 +157,7 @@ class TheJob:
job
.
result
=
'
Interní chyba, informujte prosím správce systému.
'
job
.
result
=
'
Interní chyba, informujte prosím správce systému.
'
job
.
finished_at
=
mo
.
util
.
get_now
()
job
.
finished_at
=
mo
.
util
.
get_now
()
job
.
expires_at
=
job
.
finished_at
+
timedelta
(
minutes
=
config
.
JOB_EXPIRATION
)
job
.
expires_at
=
job
.
finished_at
+
timedelta
(
minutes
=
self
.
expires_in_minutes
)
sess
.
commit
()
sess
.
commit
()
...
...
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