Welcome to 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¶
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)
Status¶
Contents¶
Acknowledgements¶
The Twisted Project and the entire Twisted community for the strong grounding in Evented Async. Libor Michalek and Slide Inc for showing me using Python coroutines at phenomenal scale isn’t completely insane. Mike Johnston and Fred Cheng for Simplenote, Simperium, the chance to experiment with how apps will work with realtime APIs and for making it possible for me to live in San Francisco. Littleinc for giving me a chance to send a lot of messages and to open source this project which I started working on while there. Justin Rosenthal for believing in me, 30% of the time. Andres Buritica who did a lot of the early HTTP and UDP fragment (not pushed just yet!) work and Alison Kosinski, the coolest wife in the world.