Giter Site home page Giter Site logo

ronnypfannschmidt-attic / flower Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benoitc/flower

0.0 2.0 0.0 157 KB

collection of modules to build distributed and reliable concurrent systems in Python.

License: Other

Racket 0.32% Python 99.68%

flower's Introduction

Flower

https://secure.travis-ci.org/benoitc/flower.png?branch=master

collection of modules to build distributed and reliable concurrent systems in Python.

Requirements

Simple example

A simple example showing how to create a consumer and use other actor function to feed it.

import flower

messages = []
sources = []
def consumer():
    # wait for coming message in the current actor
    while True:
        source, msg = flower.receive()
        if not msg:
            break
        print("got message from %s: %s" % (source.ref, msg))

def publisher1(ref):
    # an actor sending messages to the consumer
    msg = ['hello', 'world']
    for s in msg:
        flower.send(ref, s)

def publisher2(ref):
    msg = ['brave', 'new', 'world', '']
    for s in msg:
        flower.send(ref, s)

ref_consumer = flower.spawn(consumer)
flower.spawn(publisher1, ref_consumer)
flower.spawn(publisher2, ref_consumer)

flower.run()

should return:

$ python examples/actor_example.py
got message from 1: hello
got message from 2: brave
got message from 1: world
got message from 2: new
got message from 2: world

Installation

Flower requires Python superior to 2.6 (yes Python 3 is supported)

To install flower using pip you must make sure you have a recent version of distribute installed:

$ curl -O http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ easy_install pip

For now flower can only be installed from sources. To install or upgrade to the latest released version of flower:

$ git clone https://github.com/benoitc/flower.git
$ cd flower && pip install -r requirements.txt

License

flower is available in the public domain (see UNLICENSE). flower is also optionally available under the MIT License (see LICENSE), meant especially for jurisdictions that do not recognize public domain works.

flower's People

Contributors

benoitc avatar

Watchers

Ronny Pfannschmidt avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.