Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
jobmanager
Commits
5bbbcd46
Commit
5bbbcd46
authored
Nov 03, 2016
by
Andreas Valder
Browse files
non functional prototype
parent
9d903bae
Changes
2
Show whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
5bbbcd46
__pycache__
config.ini
worker.py
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment