Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Lightweight cooperative microthreads for Pyhton

Project description


Fibers are lightweight primitives for cooperative multitasking in Python. They provide means for running pieces of code that can be paused and resumed. Unlike threads, which are preemptively scheduled, fibers are scheduled cooperatively, that is, only one fiber will be running at a given point in time, and no other fiber will run until the user explicitly decides so.

When a fiber is created it will not run automatically. A fiber must be ‘switched’ into for it to run. Fibers can switch control to other fibers by way of the switch or throw functions, which switch control or raise and exception in the target fiber respectively.


import fibers

def func1():
    print "1"
    print "3"

def func2():
    print "2"
    print "4"

f1 = fibers.Fiber(target=func1)
f2 = fibers.Fiber(target=func2)

The avove example will print “1 2 3 4”, but the result was obtained by the cooperative work of 2 fibers yielding control to each other.

CI status


fibers can be installed via pip as follows:

pip install fibers


Get the source:

git clone



Mac OSX:

(XCode needs to be installed)
export ARCHFLAGS="-arch x86_64"

Microsoft Windows (with Visual Studio 2008 or 2010):

python build_ext --inplace

Running the test suite

The test suite can be run using nose:

nosetests -v


Saúl Ibarra Corretgé <>

This project would not have been possible without the previous work done in the greenlet and stacklet (part of PyPy) projects.


Unless stated otherwise on-file fibers uses the MIT license, check LICENSE file.

Supported Python versions

Python >= 2.7 and >= 3.3 are supported. Other older Python versions might work, but they are not actively tested. CPython and PyPy are supported.

Supported architectures

x86, x86-64, ARM and MIPS64 are supported.


If you’d like to contribute, fork the project, make a patch and send a pull request. Have a look at the surrounding code and please, make yours look alike.

Project details

Release history Release notifications

History Node


This version
History Node


History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
fibers-1.0.0-cp27-none-win32.whl (13.5 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 2, 2015
fibers-1.0.0-cp27-none-win_amd64.whl (13.8 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 2, 2015
fibers-1.0.0-cp33-none-win32.whl (13.5 kB) Copy SHA256 hash SHA256 Wheel cp33 Sep 2, 2015
fibers-1.0.0-cp33-none-win_amd64.whl (13.7 kB) Copy SHA256 hash SHA256 Wheel cp33 Sep 2, 2015
fibers-1.0.0-cp34-none-win32.whl (13.5 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 2, 2015
fibers-1.0.0-cp34-none-win_amd64.whl (13.7 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 2, 2015
fibers-1.0.0.tar.gz (34.6 kB) Copy SHA256 hash SHA256 Source None Sep 2, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page