Skip to main content

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


Download files

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

Source Distribution

twless-0.0.2.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file twless-0.0.2.tar.gz.

File metadata

  • Download URL: twless-0.0.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for twless-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a785b9e1fa68423815c56bee0872db4f5660f5d699c9295497664f63ded08afa
MD5 8196ce7f64822c401205824f2cf85e51
BLAKE2b-256 c6474fc2de34b8628652b496ce460a5d6ccadd749ab22aafb144acff095c1f97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page