-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Membrane.Pipeline.terminate/2 behavior #519
Conversation
…ll alive after a timeout
8620fb7
to
a94458d
Compare
….terminate update
a94458d
to
ad225d4
Compare
e85ceb6
to
fa8d515
Compare
fa8d515
to
652d066
Compare
lib/membrane/pipeline.ex
Outdated
* `timeout` - tells how much time (ms) to wait for pipeline to get gracefully | ||
terminated. Defaults to 5000. | ||
* `force?` - if set to `true` and pipeline is still alive after `timeout`, | ||
pipeline will be killed using `Process.exit/2` with second argument set to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipeline will be killed using `Process.exit/2` with second argument set to | |
pipeline will be killed using `Process.exit/2` with reason |
lib/membrane/pipeline.ex
Outdated
* `asynchronous?` - if set to `true`, pipline termination won't be blocking and | ||
will be executed in the process, which pid is returned as function result. If | ||
set to `false`, pipeline termination will be blocking and will be executed in | ||
the process, that called this function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the process, that called this function. | |
the process that called this function. |
lib/membrane/pipeline.ex
Outdated
|
||
ref = if blocking?, do: Process.monitor(pipeline) | ||
Message.send(pipeline, :terminate) | ||
{asynchronous?, opts} = Keyword.pop(opts, :asynchronous?, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use Keyword.validate!
to get all the options
lib/membrane/pipeline.ex
Outdated
Process.exit(pipeline, :kill) | ||
{:error, :timeout} | ||
else | ||
raise PipelineTerminationError, """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a separate error for that is an overkill, let's raise PipelineError
lib/membrane/pipeline.ex
Outdated
end | ||
@spec run_terminate(pipeline :: pid, timeout: timeout(), force?: boolean()) :: | ||
:ok | {:error, :timeout} | ||
def run_terminate(pipeline, opts) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have @doc false
. do_terminate
would be a better name too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing - I haven't seen the usage of the force?: true
option anywhere in the tests. Perhaps we should check if it's working with that option properly
lib/membrane/pipeline.ex
Outdated
""" | ||
@spec terminate(pipeline :: pid, Keyword.t()) :: | ||
:ok | {:error, :timeout} | ||
@spec terminate(pipeline :: pid, timeout: timeout(), force?: boolean()) :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have missed the asynchronous?
option in the spec
lib/membrane/pipeline.ex
Outdated
def call(pipeline, message, timeout \\ 5000) do | ||
GenServer.call(pipeline, message, timeout) | ||
end | ||
@spec run_terminate(pipeline :: pid, timeout: timeout(), force?: boolean()) :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That one should be somehow made "private". I known you have made it public since you can use it both directly and with the asynchronous Task
, but now we will have Membrane.Pipeline.run_terminate/2
function in the API, with a defective options list ;D
@@ -392,7 +392,7 @@ defmodule Membrane.RCPipeline do | |||
def handle_terminate_request(_ctx, state) do | |||
pipeline_event = %Terminated{from: self()} | |||
send_event_to_controller_if_subscribed(pipeline_event, state) | |||
{[], state} | |||
{[terminate: :normal], state} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's odd that that one wasn't terminating :O
6542813
to
b0055fc
Compare
8ecb4ae
to
c44f4b9
Compare
Related Jira ticket: https://membraneframework.atlassian.net/browse/MC-149