Skip to content

Latest commit

 

History

History
129 lines (93 loc) · 2.79 KB

README.md

File metadata and controls

129 lines (93 loc) · 2.79 KB

pygutters

Quick and dirty tools for the intrepid plumber

pygutters is a python library which provides very very basic functions using the gutters library for building quick and dirty interprocess or network protocols for passing around f64s. Sewer metaphors included.

Installation

Run pip install gutters.

Usage

pygutters provides two class:

  • The Gutter class, which is based on TCP/IP, perfect for multi-computer setups.

  • The Duct class, which is based on named pipes, perfect for best single-computer multi-process performances.

Gutters

You may wait for a client gutter to connect like this:

gutter = Gutter.accept("127.0.0.1:10100")

The client may then connect:

gutter = Gutter.connect("127.0.0.1:10100")

For communication, you may:

  • Send a number with Gutter.throw.
  • Receive a number with Gutter.pick_up.
  • Send an acknowledgement with Gutter.hail.
  • Receive an acknowledgement with Gutter.wait.
  • Send a number and receive an acknowledgement with Gutter.throw_and_wait.
  • Receive a number and send an acknowledgement with Gutter.pick_up_and_hail.

They are used as such:

gutter.throw(123.4)

branch = gutter.pick_up()
print(branch)

gutter.wait()

gutter.hail()

gutter.throw_and_wait(567.8)

branch = gutter.pick_up_and_hail()
print(branch)

Ducts

Ducts work essentially the same than Gutters, but performs better and are limited to the local computer.

You may wait for a client duct to connect like this:

duct = Duct.accept("duct_name")

The client may then connect:

duct = Duct.connect("duct_name")

For communication, you may:

  • Send a number with Duct.throw.
  • Receive a number with Duct.pick_up.
  • Send an acknowledgement with Duct.hail.
  • Receive an acknowledgement with Duct.wait.
  • Send a number and receive an acknowledgement with Duct.throw_and_wait.
  • Receive a number and send an acknowledgement with Duct.pick_up_and_hail.

They are used as such:

duct.throw(123.4)

branch = duct.pick_up()
print(branch)

duct.wait()

duct.hail()

duct.throw_and_wait(567.8)

branch = duct.pick_up_and_hail()
print(branch)

Installation from sources

Building requirements

py-hi-tension requires Python 3.7 or greater. To build from source, you will also need:

Building and installing

To build and install pygutters, run:

pip install .

Which creates a wheel file in target/wheels/ and installs it. If you only need the wheel file, run:

maturin build --release