Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
AURA
engine
Commits
90d457c3
Commit
90d457c3
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refactor: play command domain uses
parent
924c9af8
No related branches found
No related tags found
1 merge request
!35
ORM-less scheduling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aura_engine/scheduling/scheduler.py
+16
-14
16 additions, 14 deletions
src/aura_engine/scheduling/scheduler.py
with
16 additions
and
14 deletions
src/aura_engine/scheduling/scheduler.py
+
16
−
14
View file @
90d457c3
...
...
@@ -62,8 +62,6 @@ class TimeslotCommand(EngineExecutor):
Args:
engine (Engine): The engine
timeslot (Timeslot): The timeslot which is starting at this time
TODO refactor
"""
self
.
config
=
AuraConfig
()
self
.
engine
=
engine
...
...
@@ -145,15 +143,14 @@ class PlayCommand(EngineExecutor):
Args:
engine (Engine): The engine
items ([PlaylistItem]): One or more playlist items to be started
TODO refactor
"""
self
.
config
=
AuraConfig
()
self
.
engine
=
engine
preload_offset
=
self
.
config
.
get
(
"
preload_offset
"
)
start_preload
=
items
[
0
].
start_unix
-
preload_offset
start_play
=
items
[
0
].
start_unix
first_item
:
PlaylistItem
=
items
[
0
]
start_preload
=
first_item
.
get_start
()
-
preload_offset
start_play
=
first_item
.
get_start
()
msg
=
(
f
"
Preloading items at
{
SU
.
fmt_time
(
start_preload
)
}
,
{
preload_offset
}
seconds before
"
f
"
playing it at
{
SU
.
fmt_time
(
start_play
)
}
"
...
...
@@ -161,9 +158,9 @@ class PlayCommand(EngineExecutor):
self
.
logger
.
info
(
msg
)
# Initialize the "preload" EngineExecuter and attach a child `PlayCommand` to the
# "on_ready" event handler
timeslot_id
=
items
[
0
]
.
playlist
.
timeslot
.
timeslo
t_id
super
().
__init__
(
f
"
PRELOAD#
{
timeslot_
id
}
"
,
None
,
start_preload
,
self
.
do_preload
,
items
)
EngineExecutor
(
f
"
PLAY#
{
timeslot_
id
}
"
,
self
,
start_play
,
self
.
do_play
,
items
)
id
=
first_item
.
playlist
.
timeslot
.
ge
t_id
()
super
().
__init__
(
f
"
PRELOAD#
{
id
}
"
,
None
,
start_preload
,
self
.
do_preload
,
items
)
EngineExecutor
(
f
"
PLAY#
{
id
}
"
,
self
,
start_play
,
self
.
do_play
,
items
)
def
do_preload
(
self
,
items
:
[
PlaylistItem
]):
"""
...
...
@@ -176,7 +173,8 @@ class PlayCommand(EngineExecutor):
"""
items_str
=
ResourceUtil
.
get_items_string
(
items
)
try
:
if
items
[
0
].
get_content_type
()
in
ResourceClass
.
FILE
.
types
:
first_item
:
PlaylistItem
=
items
[
0
]
if
first_item
.
get_content_type
()
in
ResourceClass
.
FILE
.
types
:
self
.
logger
.
info
(
SU
.
cyan
(
f
"
=== preload_group(
'
{
items_str
}
'
) ===
"
))
self
.
engine
.
player
.
preload_group
(
items
)
else
:
...
...
@@ -185,7 +183,8 @@ class PlayCommand(EngineExecutor):
except
LoadSourceException
as
e
:
self
.
logger
.
critical
(
SU
.
red
(
f
"
Could not preload items
{
items_str
}
"
),
e
)
if
items
[
-
1
].
status
!=
PlaylistItem
.
PlayStatus
.
READY
:
last_item
:
PlaylistItem
=
items
[
-
1
]
if
last_item
.
play_status
!=
PlaylistItem
.
PlayStatus
.
READY
:
msg
=
f
"
Items didn
'
t reach
'
ready
'
state during preloading (Items:
{
items_str
}
)
"
self
.
logger
.
warning
(
SU
.
red
(
msg
))
...
...
@@ -200,16 +199,18 @@ class PlayCommand(EngineExecutor):
"""
items_str
=
ResourceUtil
.
get_items_string
(
items
)
self
.
logger
.
info
(
SU
.
cyan
(
f
"
=== play(
'
{
items_str
}
'
) ===
"
))
if
items
[
-
1
].
status
!=
PlaylistItem
.
PlayStatus
.
READY
:
last_item
:
PlaylistItem
=
items
[
-
1
]
if
last_item
.
play_status
!=
PlaylistItem
.
PlayStatus
.
READY
:
# Let 'em play anyway ...
msg
=
f
"
PLAY: Item(s) not yet ready to be played
"
f
"
(Items:
{
items_str
}
)
"
self
.
logger
.
critical
(
SU
.
red
(
msg
))
while
items
[
-
1
].
status
!=
PlaylistItem
.
PlayStatus
.
READY
:
while
last_item
.
play_
status
!=
PlaylistItem
.
PlayStatus
.
READY
:
self
.
logger
.
info
(
"
PLAY: Wait a little bit until preloading is done ...
"
)
time
.
sleep
(
2
)
self
.
engine
.
player
.
play
(
items
[
0
],
Player
.
TransitionType
.
FADE
)
self
.
logger
.
info
(
self
.
engine
.
scheduler
.
timetable_renderer
.
get_ascii_timeslots
())
timetable_renderer
:
utils
.
TimetableRenderer
=
self
.
engine
.
scheduler
.
timetable_renderer
self
.
logger
.
info
(
timetable_renderer
.
get_ascii_timeslots
())
#
...
...
@@ -399,6 +400,7 @@ class AuraScheduler(threading.Thread):
if
seconds_to_roll
>
0
:
# Without plenty of timeout (10s) the roll doesn't work
# TODO Check if this is still the case with Liquidsoap 2
# TODO Think if this should be externalized as a command for better testability
def
async_preroll
(
seconds_to_roll
):
seconds_to_roll
+=
sleep_offset
time
.
sleep
(
sleep_offset
)
...
...
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