Package: paco
pacoSmall and idiomatic utility library for coroutine-driven asynchronous generic programming in Python +3.4.Built on top ofasyncio,pacoprovides missing capabilities from Pythonstdlibin order to write asynchronous cooperative multitasking in a nice-ish way.
Also, paco aims to port some offunctoolsanditertoolsstandard functions to the asynchronous world.pacocan be your utility belt to deal with asynchronous, I/O-bound, non-blocking concurrent code in a cleaner and idiomatic way.FeaturesSimple and idiomatic API, extending Pythonstdlibwith async coroutines gotchas.Built-in configurable control-flow concurrency support (throttle).No fancy abstractions: it just works with the plain asynchronous coroutines.Useful iterables, decorators, functors and convenient helpers.Coroutine-based functional helpers:compose,throttle,partial,timeout,times,until,race…Asynchronous coroutines port of Python built-in functions:filter,map,dropwhile,filterfalse,reduce…Supports asynchronous iterables and generators (PEP0525)Concurrent iterables and higher-order functions.Betterasyncio.gather()andasyncio.wait()with optional concurrency control and ordered results.Works with bothasync/awaitandyield fromcoroutines syntax.Reliable coroutine timeout limit handler via context manager.Designed for intensive I/O bound concurrent non-blocking tasks.Good interoperability withasyncioand Pythonstdlibfunctions.Composable pipelinesof functors via|operator overloading.Small and dependency free.Compatible with Python +3.4.InstallationUsingpippackage manager:pipinstall--upgradepacoOr install the latest sources from Github:pipinstall-egit+git://github.com/h2non/paco.git#egg=pacoAPIpaco.ConcurrentExecutorpaco.applypaco.composepaco.concurrentpaco.constantpaco.currypaco.deferpaco.dropwhilepaco.eachpaco.everypaco.filterpaco.filterfalsepaco.flat_mappaco.gatherpaco.identitypaco.intervalpaco.mappaco.oncepaco.partialpaco.racepaco.reducepaco.repeatpaco.runpaco.seriespaco.somepaco.throttlepaco.thunkpaco.timeoutpaco.TimeoutLimitpaco.timespaco.untilpaco.waitpaco.whilstpaco.wrapsExamplesAsynchronously and concurrently execute multiple HTTP requests.importpacoimportaiohttpasyncdeffetch(url):asyncwithaiohttp.ClientSession()assession:asyncwithsession.get(url)asres:returnresasyncdeffetch_urls():urls=['https://www.google.com','https://www.yahoo.com','https://www.bing.com','https://www.baidu.com','https://duckduckgo.com',]# Map concurrent executor with concurrent limit of 3responses=awaitpaco.map(fetch,urls,limit=3)forresinresponses:print('Status:',res.status)# Run in event looppaco.run(fetch_urls())Concurrent pipeline-style composition of transform functors over an iterable object.importpacoasyncdeffilterer(x):returnx<8asyncdefmapper(x):returnx*2asyncdefdrop(x):returnx<10asyncdefreducer(acc,x):returnacc+xasyncdeftask(numbers):returnawait(numbers|paco.filter(filterer)|paco.map(mapper)|paco.dropwhile(drop)|paco.reduce(reducer,initializer=0))# Run in event loopnumber=paco.run(task((1,2,3,4,5,6,7,8,9,10)))print('Number:',number)# => 36LicenseMIT - Tomas AparicioHistoryv0.2.3 / 2018-10-23Merge pull request #42 from dylanjw/fix_syntax_errorUse getattr to avoid async keyword0.2.2 / 2018-10-09Merge pull request #40 from thatmattbone/masteradd loop param to paco.interval()fix(setup): use space based indentationfix(travis): use cpython 3.7-dev releaserefactor(errors): use “paco” prefix in exception messageschore(History): add version changesv0.2.1 / 2018-03-21fix(#37): allow overload function signatures with variadic argumentsrefactor(timeout_test): remove print statementfix(docs): bad link to API referencerefactor(docs): remove codesponsorv0.2.0 / 2017-10-21refactor(api): API breaking change that modifies behavior by raising any legit exception generated by a coroutine.feat(examples): add examples filefeat(v2): v2 pre-release, propagate raise exception if return_exceptions is Falserefactor(tests): add map error exception assertion testMerge branch ‘master’ ofhttps://github.com/h2non/pacorefactor(tests): add map error exception assertion testfeat(docs): add sponsor bannerfeat(docs): add sponsor bannerfeat(LICENSE): update copyright yearUpdate setup.pyv0.1.11 / 2017-01-28feat(api): addpaco.intervalfunction.v0.1.10 / 2017-01-11fix(each.py,map.py): fixedreturn_exceptionskwargfix(setup.py): add author emailfix(Makefile): remove package filev0.1.9 / 2017-01-06feat(api): add identity functionfeat(#31): add thunk functionfeat(package): add wheel package distributionrefactor(wraps): simplify implementationfix(History): remove indentationv0.1.8 / 2016-12-29feat(requirements): force upgrade setuptoolsfeat(#29): support async iterable and generatorsfix(docs): link to exampleschore(travis): use Python 3.6 stable release0.1.7 / 2016-12-18feat(#26): add curry function.0.1.6 / 2016-12-11feat(pipe): isolate pipe operator overload coderefactor: decorator and util functionsfeat(#11): timeout limit context manager.refactor(core): several minor refactorsfix(docs): comment out latex sphinx settingsfix(docs): use current package versionDocumentation examples improvements (#27)feat(history): updatefeat: add pool length magic method0.1.5 (2016-12-04)fix(#25): allow empty iterables in iterators functions, such asmap,filter,reduce.0.1.4 (2016-11-28)fix(#24): explicitly pass loop instance toasyncio.wait.0.1.3 (2016-10-27)feat(#17): addflat_mapfunction.feat(#18): add pipeline-style operator overloading composition.0.1.2 (2016-10-25)fix(setup.py): fix pip installation.refactor(api): minor refactors in several functions and tests.0.1.1 (2016-10-24)refactor(name): use new project name.0.1.0 (2016-10-23)First version (beta)