Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jobmanager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Video AG Infrastruktur
jobmanager
Commits
5bbbcd46
Commit
5bbbcd46
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
non functional prototype
parent
9d903bae
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
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
worker.py
+47
-3
47 additions, 3 deletions
worker.py
with
49 additions
and
3 deletions
.gitignore
0 → 100644
+
2
−
0
View file @
5bbbcd46
__pycache__
config.ini
This diff is collapsed.
Click to expand it.
worker.py
+
47
−
3
View file @
5bbbcd46
#!/usr/bin/env python3
import
config
import
requests
import
time
import
threading
import
sched
import
random
import
traceback
import
configparser
if
__name__
==
'
__main__
'
:
print
(
'
foo
'
)
config
=
configparser
.
ConfigParser
()
config
.
read
(
'
config.ini
'
)
scheduler
=
sched
.
scheduler
()
def
run_scheduler
():
time
.
sleep
(
1
)
# weird things on startup
while
True
:
scheduler
.
run
()
time
.
sleep
(
10
)
def
sched_func
(
delay
,
priority
=
0
,
firstdelay
=
None
,
args
=
[],
kargs
=
{}):
print
(
delay
)
if
firstdelay
==
None
:
firstdelay
=
random
.
randint
(
1
,
10
)
def
wrapper
(
func
):
def
sched_wrapper
():
try
:
func
(
*
args
,
**
kargs
)
except
Exception
:
traceback
.
print_exc
()
scheduler
.
enter
(
delay
,
priority
,
sched_wrapper
)
scheduler
.
enter
(
firstdelay
,
priority
,
sched_wrapper
)
return
func
return
wrapper
threading
.
Thread
(
target
=
run_scheduler
,
daemon
=
True
).
start
()
@sched_func
(
5
)
def
ping_website
():
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/ping
'
,
params
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
host
'
:
config
[
'
MAIN
'
][
'
HOST
'
]})
if
not
r
.
status_code
==
200
:
print
(
"
Error sending ping:
"
,
r
)
@sched_func
(
10
)
def
get_jobs
():
r
=
requests
.
post
(
config
[
'
API
'
][
'
BASE
'
]
+
'
/jobs/api/schedule
'
,
json
=
{
'
apikey
'
:
config
[
'
API
'
][
'
KEY
'
],
'
host
'
:
config
[
'
MAIN
'
][
'
HOST
'
],
'
jobtypes
'
:
'
thumbnail
'
})
print
(
r
.
text
)
while
True
:
time
.
sleep
(
10
)
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