This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with {:ok, algorithm_result} <- PythonWorker.call(json_input), | |
{:ok, stacks} <- Jason.decode(algorithm_result) do | |
{:ok, stacks} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_call({:optimize, json_input}, _from, pid) do | |
result = :python.call(pid, :optimize, :optimize, [json_input]) | |
{:reply, {:ok, result}, pid} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call(json_input) do | |
Task.async(fn -> | |
:poolboy.transaction( | |
:worker, | |
fn pid -> | |
GenServer.call(pid, {:optimize, json_input}) | |
end, | |
@timeout | |
) | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define workers and child supervisors to be supervised | |
children = [ | |
# Poolboy python initialization | |
:poolboy.child_spec(:worker, python_poolboy_config()) | |
] | |
defp python_poolboy_config do | |
[ | |
{:name, {:local, :worker}}, | |
{:worker_module, Monocle.AutoStacking.PythonWorker}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:poolboy, "~> 1.5"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = :python.call(pid, :optimize, :optimize, [json_input]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:ok, pid} = :python.start([{:python_path, to_charlist(path)}, {:python, 'python3'}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = [:code.priv_dir(:monocle), "python"] |> Path.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:erlport, "~> 0.10.1"} |