Skip to main content

fibers: lightweight concurrent multitasking

https://badge.fury.io/py/fibers.png

Overview

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.

Example:

import fibers

def func1():
    print "1"
    f2.switch()
    print "3"
    f2.switch()

def func2():
    print "2"
    f1.switch()
    print "4"

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

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

https://secure.travis-ci.org/saghul/python-fibers.png?branch=master https://ci.appveyor.com/api/projects/status/9f4h0wk797i4vc0k?svg=true

Documentation

http://readthedocs.org/docs/python-fibers/

Installing

fibers can be installed via pip as follows:

pip install fibers

Building

Get the source:

git clone https://github.com/saghul/python-fibers

Linux:

./build_inplace

Mac OSX:

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

Microsoft Windows:

python setup.py build_ext --inplace

Running the test suite

The test suite can be run using nose:

nosetests -v

Author

Saúl Ibarra Corretgé <saghul@gmail.com>

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

License

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, MIPS64, PPC64 and s390x are supported.

Contributing

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.

Metadata

Release files for fibers 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fibers 1.1.0
File Size Uploaded Provenance Actions
fibers-1.1.0.tar.gz 36.1 kB Without provenance Details for fibers-1.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fibers 1.1.0
File Actions
fibers-1.1.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details for fibers-1.1.0-cp36-cp36m-win_amd64.whl
fibers-1.1.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details for fibers-1.1.0-cp36-cp36m-win32.whl
fibers-1.1.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details for fibers-1.1.0-cp35-cp35m-win_amd64.whl
fibers-1.1.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details for fibers-1.1.0-cp35-cp35m-win32.whl
fibers-1.1.0-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details for fibers-1.1.0-cp34-cp34m-win_amd64.whl
fibers-1.1.0-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details for fibers-1.1.0-cp34-cp34m-win32.whl
fibers-1.1.0-cp33-cp33m-win_amd64.whl CPython 3.3 CPython 3.3 pymalloc Windows x86-64 Details for fibers-1.1.0-cp33-cp33m-win_amd64.whl
fibers-1.1.0-cp33-cp33m-win32.whl CPython 3.3 CPython 3.3 pymalloc Windows x86-32 Details for fibers-1.1.0-cp33-cp33m-win32.whl
fibers-1.1.0-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details for fibers-1.1.0-cp27-cp27m-win_amd64.whl
fibers-1.1.0-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details for fibers-1.1.0-cp27-cp27m-win32.whl

Total release size: 183.3 kB

Release files / fibers-1.1.0.tar.gz

Download URL fibers-1.1.0.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
624de9b23547838459765fa2386c31afea414fca34558895e2f867eeacbb4fce
BLAKE2b-256 checksum
How to use checksums
91127b683d9589d3052d3d5366529e60db58f797b4ffd4b1146b86488f736ab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp36-cp36m-win_amd64.whl

Download URL fibers-1.1.0-cp36-cp36m-win_amd64.whl
Size 16.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
5416584f3d06144ba25fc2304c7643ce4812b9a4b366fa9271a093d6293e96ee
BLAKE2b-256 checksum
How to use checksums
183e2e8ed0e30860fba8dfd280d17ea2a977085b705e43224d7c45ea98e5b906
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp36-cp36m-win32.whl

Download URL fibers-1.1.0-cp36-cp36m-win32.whl
Size 15.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
89c099bcc523d1227392f9e8d72fee958d19dbf2003d089af4a7d2b8b03399de
BLAKE2b-256 checksum
How to use checksums
c848629c16b9af1e9670fa65b16c1adc36f1310106fc4ed1f6e7dadae0408387
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp35-cp35m-win_amd64.whl

Download URL fibers-1.1.0-cp35-cp35m-win_amd64.whl
Size 16.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
443ee28e8284c1002a76480dfce301be710de1e30df1f6d4a6558ad71d1bf6d5
BLAKE2b-256 checksum
How to use checksums
440ef0bc709341dc3c3b005aa6087397bbbe9e87dcd3d981a9390d4d1ea309de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp35-cp35m-win32.whl

Download URL fibers-1.1.0-cp35-cp35m-win32.whl
Size 15.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
40f7fac249a7701f1e775db025583b773b401bdb48fa4e1c234497935b336bde
BLAKE2b-256 checksum
How to use checksums
bb462958f5a535f29fa9ac53a91663e71e548d46db35a8b1a1466c1eb5899b15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp34-cp34m-win_amd64.whl

Download URL fibers-1.1.0-cp34-cp34m-win_amd64.whl
Size 14.2 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c105d8665a48a2ccbacd2217bbaa8f113225ebba72bec89c999d33c8844cee03
BLAKE2b-256 checksum
How to use checksums
5c91fa1adbd68084b727dcd514289ac5f4de90cd191258202afa64d0c77acb2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp34-cp34m-win32.whl

Download URL fibers-1.1.0-cp34-cp34m-win32.whl
Size 13.9 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
65b5514a2a1905e7b3497abc26ba5bb11bd324d304174d90f7cfefd348373f20
BLAKE2b-256 checksum
How to use checksums
4d9f37e59266ff7d364f39255e349b457c360d43c4db719f5909fcfd15306a1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp33-cp33m-win_amd64.whl

Download URL fibers-1.1.0-cp33-cp33m-win_amd64.whl
Size 14.2 kB
Tags CPython 3.3 CPython 3.3 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
1fdb8be79578936c48c7b4c98229ee75b0048a4a4475438e2179ba1165bd22e4
BLAKE2b-256 checksum
How to use checksums
4fec4030ba89ca323ae411e82b5b7738b0a68730404246bdcb3a811298aba99c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp33-cp33m-win32.whl

Download URL fibers-1.1.0-cp33-cp33m-win32.whl
Size 13.9 kB
Tags CPython 3.3 CPython 3.3 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
211ad4888ba7a3ab6ebfedd3b2739c217f437f8c391470feaa6f84caf3843285
BLAKE2b-256 checksum
How to use checksums
a5f1261f3f4844080913e0b20419fd249d99501682c38ab33744f585eed82ada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp27-cp27m-win_amd64.whl

Download URL fibers-1.1.0-cp27-cp27m-win_amd64.whl
Size 14.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
83cabfee73774dd4fa7ecd7ed22a7709674a13800bb6a95ca2d61744f259bdee
BLAKE2b-256 checksum
How to use checksums
d2a19849a0d79c3463ed19893fd726fa569b24ac619d0a5bd75c060e8da4434a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fibers-1.1.0-cp27-cp27m-win32.whl

Download URL fibers-1.1.0-cp27-cp27m-win32.whl
Size 14.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
be6d6dfb308294482db2f5b81be51d078636eac2621f55b09f1501ed5bed3337
BLAKE2b-256 checksum
How to use checksums
5b8080917c0750a84a5fa23fba37ebb62973e7c0fc91c721af574c3d4c67093c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for fibers 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page