You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a race condition when a player is started and very quickly exits, before the code has a chance to register an exitEvent handler.
Problem reproduction
The following program wants to print "Exit", but does not. The sleep in there is to artificially enlarge the window for the race condition to occur. Without the sleep, this will usually print "Exit", but there might be rare cases where the process quits before the exitEvent is registered.
from omxplayer.player import OMXPlayer
from pathlib import Path
from time import sleep
player = OMXPlayer(Path("/dev/null"))
sleep(1)
player.exitEvent += lambda p, e: print("Exit")
A structure like this is important for a program that wants to keep playing things. That needs some way to guarantee that the exitEvent handler is always run, so it can start playing something else even when the player exits immediately due to whatever reason.
AFAICS, there is currently no way to fix this race condition. To do so, you would need to register the exitEventbefore the player is started, which is currently impossible.
Maybe a solution could be combined with #161, which suggests adding a no-argument constructor to start a player and a load() method to switch to a different source. If that constructor would not start the player, just construct the object and there would be either a separate start() method, or the first call to load() would start the player, then there would be a safe window to register the exitEvent handler.
Issue Report
Description
There is a race condition when a player is started and very quickly exits, before the code has a chance to register an
exitEvent
handler.Problem reproduction
The following program wants to print "Exit", but does not. The sleep in there is to artificially enlarge the window for the race condition to occur. Without the sleep, this will usually print "Exit", but there might be rare cases where the process quits before the
exitEvent
is registered.A structure like this is important for a program that wants to keep playing things. That needs some way to guarantee that the
exitEvent
handler is always run, so it can start playing something else even when the player exits immediately due to whatever reason.AFAICS, there is currently no way to fix this race condition. To do so, you would need to register the
exitEvent
before the player is started, which is currently impossible.Maybe a solution could be combined with #161, which suggests adding a no-argument constructor to start a player and a
load()
method to switch to a different source. If that constructor would not start the player, just construct the object and there would be either a separatestart()
method, or the first call toload()
would start the player, then there would be a safe window to register theexitEvent
handler.Environment details
lsb_release -a
):python-omxplayer-wrapper
0.3.2
python-dbus
(dpkg -s python-dbus
)1.2.12
python
(python --version
)3.7.3
omxplayer
(omxplayer --version
)f543a0d
The text was updated successfully, but these errors were encountered: