This repository contains examples of using Effect. They demonstrate basic use of Effect to isolate side-effects from code, but also to provide alternative implementations of those side-effecting actions without requiring changes to core application logic.
This package isn't meant to be installed, but rather just copied to your local
dev environment and tinkered with. To install dependencies use
pip install -r requirements.txt.
treq is a Twisted-based library, showing that Effect can be used (with the
additional txeffect package) to
write generic code that can use either Twisted-based asynchronous IO or normal
blocking IO. Other asynchronous frameworks (such as Python 3's
could also be used in this way.
readline_intent.py file has a simple
intent that uses
input in Py3) to prompt the user for input.
github directory contains a simple application that lets the user input a
GitHub username and prints out a list of all repositories that that user has
access to. It depends on the
Note that if you run this example too rapidly, GitHub might temporarily block your IP from making anonymous API requests for some short period of time.
There are two entrypoints into the example:
typical blocking IO, and
twisted_main uses asynchronous IO. Note that the
vast majority of the code doesn't need to care about this difference; the only
part that cares about it is the
*_main.py files. All of the logic in
core.py is generic.
To run them:
python -m github.sync_main
python -m github.twisted_main
Note that the twisted example does not run on Python 3, but all other examples do.
The github example app has unit tests in
test_core.py. They can be discovered and run simply by
py.test in the top-level directory.