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
64e29a3d
Commit
64e29a3d
authored
Apr 12, 2017
by
Andreas Valder
Browse files
even faster thumbnails
parent
44ec93b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
manager.py
View file @
64e29a3d
...
...
@@ -43,6 +43,7 @@ def ping_website_for_host():
if
not
api
.
worker_ping
():
print
(
"Error sending host ping"
)
@
sched_func
(
5
)
def
get_job
():
if
psutil
.
cpu_percent
(
interval
=
3
)
>
85
:
return
...
...
@@ -51,6 +52,7 @@ def get_job():
return
print
(
"id: %i, data: %s, all: %s"
%
(
j
[
'id'
],
j
[
'data'
],
j
))
subprocess
.
Popen
([
'./worker.py'
,
str
(
j
[
'id'
]),
str
(
j
[
'type'
]),
str
(
j
[
'priority'
])
,
str
(
j
[
'data'
])
]
)
print
(
"forked"
)
while
True
:
get_job
(
)
time
.
sleep
(
10
)
worker.py
View file @
64e29a3d
...
...
@@ -26,7 +26,7 @@ if (jobtype == 'thumbnail'):
api
.
job_ping
(
id
=
id
)
duration
=
float
(
subprocess
.
run
([
"ffprobe"
,
"-v"
,
"error"
,
"-show_entries"
,
"format=duration"
,
"-of"
,
"default=noprint_wrappers=1:nokey=1"
,
inputfile
],
stdout
=
subprocess
.
PIPE
).
stdout
)
api
.
job_ping
(
id
=
id
)
if
subprocess
.
run
([
"ffmpeg"
,
"-loglevel"
,
"error"
,
"-ss"
,
str
(
duration
*
0.4
),
"-i"
,
inputfile
,
"-vf"
,
"scale=640:
360
"
,
"-frames:v"
,
"1"
,
outputfile
]).
returncode
==
0
:
if
subprocess
.
run
([
"ffmpeg"
,
"-loglevel"
,
"error"
,
"-y"
,
"-ss"
,
str
(
duration
*
0.4
),
"-i"
,
inputfile
,
"-vf"
,
"scale=640:
-1
"
,
"-frames:v"
,
"1"
,
outputfile
]).
returncode
==
0
:
api
.
job_ping
(
id
=
id
,
state
=
'finished'
)
else
:
api
.
job_ping
(
id
=
id
,
state
=
'failed'
)
...
...
Write
Preview
Markdown
is supported
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