RustySnek / Venomous

An Erlport wrapper for concurrent use of Python processes.
GNU General Public License v3.0
15 stars 2 forks source link

Unexpected return values and process exits after Python worker timeout #24

Closed specv closed 3 months ago

specv commented 3 months ago

After a Python function call times out, subsequent calls behave unexpectedly:

  1. When a Python function call times out, it correctly returns a timeout error.
  2. The next call to a Python function returns an %ErlangError{original: :stopped, reason: nil}.
  3. Any further attempts to call a Python function cause the current process to exit.

To reproduce this issue, you can use the following code:

import ExUnit.Assertions
import Venomous
import Venomous.SnakeArgs

# First call: Timeout
assert from_params(:time, :sleep, [2])
       |> python(python_timeout: 1000) ==
         %{error: :timeout}

# Second call: ErlangError
assert from_params(:operator, :add, [1, 1]) |> python() ==
         %ErlangError{original: :stopped, reason: nil}

# Third call: Process exit
assert catch_exit(
         from_params(:operator, :add, [1, 1])
         |> python()
       ) == :normal
RustySnek commented 3 months ago

Pretty crazy ngl. I remember finding it myself and kind of forgetting about it. The issue was multiple things. First was that I used Task.run() which wouldn't really get terminated alongside the genserver Second was that it was sometimes capturing exit signal from the Port that was killed alongside python process. Third was that sometimes before the genserver got killed, it returned the ErlangError that indicates that the erlport python process was stopped.

Should be fixed with #25 I will probably release it with the #23 once im done with it Thanks for the report 😄