History

client API: kill async commands on termination

This affects async commands started by client API, commands with async capability run in a sync way by client API (think mpv_command_node() with "subprocess"), and detached async work. Since scripts might want to do some cleanup work (that might involve launching processes, don't ask), we don't unconditionally kill everything on exit, but apply an arbitrary timeout of 2 seconds until async commands are aborted.

wm4 committed 8 years ago

Commit 7428cc51 parent 4e05f755 files · +65 −14Browse files

Showing the changes to TOOLS/lua/command-test.lua (1 of 5 files). Show all

Unified · Split

TOOLS/lua/command-test.lua+16−0
@@ -64,4 +64,20 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 63 unmodified lines
64 print("aborting sleep inf subprocess after timeout")64 print("aborting sleep inf subprocess after timeout")
65 mp.abort_async_command(x)65 mp.abort_async_command(x)
66 end)66 end)
67
68 -- This should get killed on script exit.
69 mp.command_native_async({name = "subprocess", playback_only = false,
70 args = {"sleep", "inf"}}, function()end)
71
72 -- Runs detached; should be killed on player exit (forces timeout)
73 mp.command_native({_flags={"async"}, name = "subprocess",
74 playback_only = false, args = {"sleep", "inf"}})
75end)
76
77mp.register_event("shutdown", function()
78 -- This "freezes" the script, should be killed via timeout.
79 print("freeze!")
80 local x = mp.command_native({name = "subprocess", playback_only = false,
81 args = {"sleep", "inf"}})
82 print("done, killed=" .. utils.to_string(x.killed_by_us))
67end)83end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t