-
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
Fix bug in handling actions returned from handle_tick. Deprecate handle_spec_started. #708
Conversation
This reverts commit 168f57e.
0380d86
to
3630ef2
Compare
3630ef2
to
0e40638
Compare
927285a
to
990172b
Compare
4ec86bf
to
47e97c9
Compare
Membrane.Logger.warning(""" | ||
Action :spec was returned from handle_spec_started/3 callback. It is suggested not to do this, | ||
because it might lead to infinite loof of handle_spec_started/3 executions. | ||
""") |
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.
I'd not make this a warning, as this may be a valid situation as well.
|
||
@impl CallbackHandler | ||
def handle_end_of_actions(state) do | ||
ChildLifeController.trigger_specs(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.
This may be problematic, as we one can do [spec: child(:foo, Foo), notify_child: {:foo, :ping}]
. I think we should only delay the callback execution.
@@ -191,6 +192,9 @@ defmodule Membrane.Core.CallbackHandler do | |||
was_handling_action? = state.handling_action? | |||
state = %{state | handling_action?: true} | |||
|
|||
was_supplying_demand? = Map.get(state, :supplying_demand?, 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 add a comment that it's a temporary fix
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.
lib/membrane/bin.ex
Outdated
require Membrane.Core.Parent | ||
Membrane.Core.Parent.bring_after_compile_check() |
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.
require Membrane.Core.Parent | |
Membrane.Core.Parent.bring_after_compile_check() | |
@after_compile {Membrane.Core.Parent, :check_for_deprecated_callbacks} |
lib/membrane/core/parent.ex
Outdated
defmacro bring_after_compile_check() do | ||
quote do | ||
@after_compile {__MODULE__, :__membrane_check_deprecated_functions__} | ||
|
||
@spec __membrane_check_deprecated_functions__(Macro.Env.t(), binary) :: :ok | ||
def __membrane_check_deprecated_functions__(env, _bytecode) do | ||
modules_whitelist = [Membrane.Testing.Pipeline] | ||
|
||
if env.module not in modules_whitelist and | ||
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do | ||
warn_message = """ | ||
Callback handle_spec_started/3 has been deprecated since \ | ||
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)} | ||
""" | ||
|
||
IO.warn(warn_message, []) | ||
end | ||
|
||
:ok | ||
end | ||
end | ||
end |
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.
defmacro bring_after_compile_check() do | |
quote do | |
@after_compile {__MODULE__, :__membrane_check_deprecated_functions__} | |
@spec __membrane_check_deprecated_functions__(Macro.Env.t(), binary) :: :ok | |
def __membrane_check_deprecated_functions__(env, _bytecode) do | |
modules_whitelist = [Membrane.Testing.Pipeline] | |
if env.module not in modules_whitelist and | |
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do | |
warn_message = """ | |
Callback handle_spec_started/3 has been deprecated since \ | |
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)} | |
""" | |
IO.warn(warn_message, []) | |
end | |
:ok | |
end | |
end | |
end | |
def check_for_deprecated_callbacks(env, _bytecode) do | |
modules_whitelist = [Membrane.Testing.Pipeline] | |
if env.module not in modules_whitelist and | |
Module.defines?(env.module, {:handle_spec_started, 3}, :def) do | |
warn_message = """ | |
Callback handle_spec_started/3 has been deprecated since \ | |
:membrane_core v1.0.1, but it is implemented in #{inspect(env.module)} | |
""" | |
IO.warn(warn_message, []) | |
end | |
:ok | |
end |
lib/membrane/pipeline.ex
Outdated
@@ -204,9 +204,11 @@ defmodule Membrane.Pipeline do | |||
) :: {[Action.common_actions()], state()} | |||
|
|||
@doc """ | |||
This callback is deprecated since v1.0.1. |
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.
If we deprecate the callback, I'd go for releasing the current master as v1.0.1 and release this as v1.1.0-rc0 with auto flow queues
Closes #695
Closes #752
Relates to #753