Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

UNKNOWN

Project Description
Sprinkler
=========
A small python library that helps you write co-routines
in an event-driven way. In short it 'sprinkles' data passed
to the '.sprinkle' function to all sub-classes of 'Task' in
a round robin manner.

A simple example:

from pysprinkler import Task, Sprinkler

class RemoteDBHandler(Task):

def __init__(self):
print("Started RemoteDBHandler")

def on_data(self, data):
print("RemoteDBHandler: {}".format(data))

def on_end(self):
print("Closing RemoteDBHandler")


class LocalDBHandler(Task):

def __init__(self):
print("Started LocalDBHandler")

def on_data(self, data):
print("LocalDBHandler: {}".format(data))

def on_end(self):
print("Closing LocalDBHandler")

class STNHandler(Task):

def __init__(self):
print("Started STNHandler")

def on_data(self, data):
print("STNHandler: {}".format(data))

def on_end(self):
print("Closing STNHandler")

rdb_handler = RemoteDBHandler()
ldb_handler = LocalDBHandler()
stn_handler = STNHandler()

s = Sprinkler([rdb_handler, ldb_handler, stn_handler])
s.start()

lines = ["Line 1", "Line 2", "Line 3", "Line 4", "Line 5"]
for line in lines:
# sends 'line' to all 'Task's in a
# round robin manner
s.sprinkle(line)
s.close()

Output:

Started RemoteDBHandler
Started LocalDBHandler
Started STNHandler
RemoteDBHandler: Line 1
LocalDBHandler: Line 1
STNHandler: Line 1
RemoteDBHandler: Line 2
LocalDBHandler: Line 2
STNHandler: Line 2
RemoteDBHandler: Line 3
LocalDBHandler: Line 3
STNHandler: Line 3
RemoteDBHandler: Line 4
LocalDBHandler: Line 4
STNHandler: Line 4
RemoteDBHandler: Line 5
LocalDBHandler: Line 5
STNHandler: Line 5
Closing RemoteDBHandler
Closing LocalDBHandler
Closing STNHandler
Release History

Release History

This version
History Node

1.1

History Node

1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pysprinkler-1.1.tar.gz (1.7 kB) Copy SHA256 Checksum SHA256 Source Jun 14, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting