Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

a coroutine framework based on twisted and stackless python

Project description

twless is a coroutine framework based on twisted and stackless python.
it provide simple and nature way to create coroutining runtime envirement,no async/await, yield , callback infection and circling is needed,eveything is just straight-forward,easy to understand.

look at this simple example:

from twless.schedule import runReactor,exitReactor,startUserTasklet
from twless.context import sleepInTasklet

class TestContext:
    counter = 0

def worker(idx):
    '''

        tasklet(coroutine) execute function

    '''
    print('worker #{0} start...'.format(idx))
    # sleep 1 second and continue.
    sleepInTasklet(1)
    print('worker #{0} finish.'.format(idx))
    TestContext.counter -= 1
    if TestContext.counter <= 0:
        # when all workers finish,exit from current process.
        exitReactor()

def main():
    #
    # start up 100 tasklet(coroutine)
    for idx in xrange(100):
        startUserTasklet(worker,idx)
        TestContext.counter += 1


if __name__ == '__main__':
    runReactor(main)

Project details


Release history Release notifications

This version

0.0.2

Download files

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

Files for twless, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size twless-0.0.2.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

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