Skip to main content

Straightforward concurrency for Python http://vanillapy.readthedocs.org/

Project description

If Go and ZeroMQ had a baby, and that baby grew up and started dating PyPy, and they had a baby, it might look like Vanilla.

Overview

Vanilla allows you to build concurrent software in Python. Vanilla programs are structured around independent coroutines (greenlets) which communicate with each other via Pipes. Pipes are similar to channels in Go programming.

There’s no callback crazyness and no monkey patching. Vanilla strives to be as explict and straightforward as possible.

Documentation

Read the Docs

Here’s how it looks:

You spawn coroutines:

h = vanilla.Hub()

def beat(message):
    while True:
        print(message)
        h.sleep(1000)

h.spawn(beat, 'Tick')
h.spawn_later(500, beat, 'Tock')
# Tick / Tock / Tick / Tock

Coroutines communicate via Pipes:

h = vanilla.Hub()
sender, recver = h.pipe()
h.spawn(sender.send, 'Hello World')
recver.recv()
# 'Hello World'

Pipe-fu; inspired by reactive functional patterns, Pipes can be chained:

h = vanilla.Hub()
p = h.pipe().map(lambda x: x*2)
h.spawn(p.send, 4)
p.recv()
# 8

In Vanilla, everything is a Pipe. Here’s how TCP looks:

h = vanilla.Hub()

server = h.tcp.listen(port=9000)
# server is a Recver which dispenses new TCP connections

conn = server.recv()
# conn is a Pipe you can recv and send on

message = conn.recv()
conn.send("Echo: " + message)

Installation

Vanilla works with Python 2.6 - 2.9 and PyPy.

pip install vanilla

Status

Build StatusCoverage Status

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vanilla-0.1.16.tar.gz (22.7 kB view details)

Uploaded Source

File details

Details for the file vanilla-0.1.16.tar.gz.

File metadata

  • Download URL: vanilla-0.1.16.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vanilla-0.1.16.tar.gz
Algorithm Hash digest
SHA256 cdfcc4519e155cd9dd19bf7b24cfbbe12a36bef223038e73f6acc68df2320828
MD5 0b2d187e993fe3833e349cb0c9e69765
BLAKE2b-256 b74436b17de8c84b4217321de7e12c420632fc24c108611aceea1c471ab5885d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page