RustySnek

RustySnek

:snake: :test_tube: Venomous aims to simplify the concurrent use of erlport Python Ports, focusing on dynamic extensibility such as spawning, reusing, and terminating processes on demand. It also handles unused processes, by killing them once they pass their configured inactive TTL. Venomous core functions ensure that whenever :boom: :EXIT signal appears, the Python process dies without further execution by killing :axe: its OS process (brutally).

This is my first attempt at creating an Elixir library. The idea stemmed from the challenge of properly exiting Python processes. Even after closing the Python port, execution would persist until the end of a function or iteration. My goal is to handle these exits effectively while also enabling process reuse, thus avoiding the constant spawning and stopping of new ones.

Any feedback would be greatly appreciated :smiling_face:

https://github.com/RustySnek/Venomous/

Showing Posts 1 to 10

RustySnek

RustySnek OP

I’ve released 0.3.0 version of Venomous :snake:

  • fixed many major issues with how python processes were handled which caused zombie processes and weird behaviour.
  • multiple tasks ran on a single SnakeWorker will now stack instead of timing out
  • add option keywords

Changelog: Release v0.3.0 · RustySnek/Venomous · GitHub

kip

kip

ex_cldr Core Team

Congrats on your first Elixir library. I like the delicious irony too that pythons aren’t venomous :slight_smile:

RustySnek

RustySnek OP

They must have drank some kind of toxic MIXture :wink:

jackalcooper

jackalcooper

thanks so much! I am using NimblePool to wrap python process running models. Your implementation to manage python process is way more sophisticated than mine so I guess I’m going to use it :growing_heart:

xsteve

xsteve

Thanks for providing that library.
However, I am unsure how to use it.
The documentation shows how to call a single python function.
Would you please explain how the python interpreter is started. How do I import some python modules and declare the function I want to call?

RustySnek

RustySnek OP

Hey so basically as of now, all of the python modules (files) are loaded from PYTHONPATH env variable. So if you put your python modules inside python/ directory you would have to add that directory to PYTHONPATH envvar.

There is also a config for Venomous python processes to load the type encoder/decoder of erlport. I made a quick guide to this here: Quick guide on erlport Python API — Venomous v1.0.0

As for calling mutiple python instances you have to do it yourself for example.

 args = SnakeArgs.from_params(:time, :sleep, [0.1])
    1..100
    |> Enum.map(fn _ ->
      Task.async(fn -> python!(args) end)
    end)
    |> Task.await_many(:infinity)

Here Venomous will spawn as many processes as its allowed to via max_children configuration of SnakeSupervisor up to a 100. If it can’t spawn anymore it will just wait and reuse the already spawned ones once they are done with their tasks.

Feel free to ask if you need any more help. :smiling_face:

xsteve

xsteve

Thanks for the explanation. I guess I understand it now.
Perhaps it would be nice to put the python code “time.sleep(0.1)” also somewhere into the documentation. And also add the needed usage of PYTHONPATH when there is a need to call an own python module (which will be the case most of the time)

RustySnek

RustySnek OP

Yeah I’ll probably extend documentation and add few examples in the next release

RustySnek

RustySnek OP

I’ve released 0.4.0 version of Venomous :test_tube: :snake:

  • Included support for erlport python options. ex. module_paths, python_executable, packet_bytes..
  • Add named processes, separate from the regular SnakeManager ones
  • Fixed issue with lib breaking whenever python process was killed on exception…
  • Quicker exits whenver processes are spammed
  • Include examples in docs

Changelog: Release v0.4.0 · RustySnek/Venomous · GitHub

RustySnek

RustySnek OP

I’ve released 0.5.1 version of Venomous :test_tube: :snake: which adds optional :fire: Hot reloading for python modules.

To enable the hot reloading:

  • Install python watchdog dependancy using mix venomous.watchdog install
  • Enable serpent_watcher in your dev config:
    config :venomous, :serpent_watcher, enable: true
    
  • Add your module paths in snake_manager config:
    config :venomous, :snake_manager, %{
      python_opts: [
        module_paths: ["my_python_modules/", ...]
      ]
    }
    

Now all modules inside the configured module_paths should reload on edit.

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
lawik
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./ The firs...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews