Saravanan666/pypi-org huggingface dataset:
Package: aiotaskq
aiotaskqA simple asynchronous task queueMotivationPopular asynchronous worker library likeCelerydoesn't support asyncio and is hard to use for advanced usage.aiotaskqaims to help users compose tasks in a very native async-await manner.Plus, it is also fully-typed for better productivity and correctness.Give it a try and let us know if you like it. For questions or feedback feel to file issues on this repository.Example UsageInstall aiotaskqpython-mpipinstall--upgradepip
pipinstallaiotaskqDefine a simple app like the following:tree.
.
└──app└──app.pyWhereapp.pycontains the following:importasyncioimportaiotaskq@aiotaskq.taskdefsome_task(b:int)->int:# Some task with high cpu usagedef_naive_fib(n:int)->int:ifn<=2:return1return_naive_fib(n-1)+_naive_fib(n-2)return_naive_fib(b)asyncdefmain():async_result=awaitsome_task.apply_async(42)sync_result=some_task(42)assertasync_result==sync_resultprint(f"sync_result == async_result == 165580141. Awesome!")if__name__=="__main__":loop=asyncio.get_event_loop()loop.run_until_complete(main())Start redisdockerrun--publish127.0.0.1:6379:6379redisIn a different terminal, start the aiotaskq workerpython-maiotaskqworkerapp.appThen in another different terminal, run your apppython./app.py# Output: sync_result == async_result == 165580141. Awesome!Advanced usage exampleLet's say we want to compose a workflow where we want to break up some of the tasks and run them in parallel:|-- task_2 --> |
                    |-- task_2 --> |     | task_3 --> |
START -> task_1 --> |-- task_2 --> | --> | task_3 --> | --> task_4 --> FINISH
                    |-- task_2 --> |     | task_3 --> |
                    |-- task_2 --> |Usingcelerywe might end up with thisfromceleryimportCeleryapp=Celery()@app.taskdeftask_1(*args,**kwargs):pass@app.taskdeftask_2(*args,**kwargs):pass@app.taskdeftask_3(*args,**kwargs):pass@app.taskdeftask_4(*args,**kwargs):passif__name__=="__main__":step_1=task_1.si(some_arg="a")step_2=[task_2.si(some_arg=f"{i}")foriinrange(5)]step_3=[task_3.si(some_arg=f"{i}")foriinrange(3)]step_4=task_4.si(some_arg="b")workflow=chord(header=step_1,body=chord(header=step_2,body=chord(header=step_3,body=step_4,),),)output=workflow.apply_async().get()print(output)Usingaiotaskqwe may end up with the following:importasynciofromaiotaskqimporttask@taskdeftask_1(*args,**kwargs):pass@taskdeftask_2(*args,**kwargs):pass@taskdeftask_3(*args,**kwargs):pass@taskdeftask_4(*args,**kwargs):pass# So far the same as celery# And now the workflow is just native python, and you're free# to use any `asyncio` library of your choice to help with composing# your workflow e.g. `trio` to handle more advanced scenarios like# error propagation, task cancellation etc.if__name__=="__main__":step_1=task_1.apply_async()step_2=asyncio.gather(task_2.apply_async(arg=f"{i}"foriinrange(5)))step_3=asyncio.gather(task_3.apply_async(arg=f"{i}"foriinrange(3)))step_4=task_4.apply_async()workflow=[step_1,step_2,step_3,step_4]output=awaitasyncio.gather(workflow)print(output)InstallpipinstallaiotaskqDevelopmentsource./activate.shTestsIn another terminal./docker.shIn the main terminalsource./activate.sh
./test.shLinksPYPI
Package: aiotasks
aiotasks========![Logo](doc/source/_static/logo.jpg)*aiotasks: Celery like task manager for new AsyncIO Python module*Code | https://github.com/cr0hn/aiotasks---- | ----------------------------------------------Issues | https://github.com/cr0hn/aiotasks/issues/Python version | Python 3.5 and aboveWhat's aiotasks---------------aiotasks is an asynchronous task queue/job queue based on distributed message passing based on Python asyncio framework. Based on the Celery Task Queue ideas, but focusing in performance, non-blocking, event-driven.What's new?-----------This aiotasks version, add a lot of new features and fixes, like:Version 1.0.0+++++++++++++- First version releasedYou can read entire list in CHANGELOG file.Installation------------Simple++++++Install aiotasks is so easy:```$ python3.5 -m pip install aiotasks```With extra performance++++++++++++++++++++++Aiotasks also includes some optional dependencies to add extra performance but requires a bit different installation, because they (usually) depends of C extensions.To install the tool with extra performance you must do:```$ python3.5 -m pip install 'aiotasks[performance]'```**Remember that aiotasks only runs in Python 3.5 and above**.Quick start-----------You can display inline help writing:From cloned project+++++++++++++++++++```bashpython aiotasks.py -h```From pip installation+++++++++++++++++++++```bashaiotasks -h```
Package: aio.tasks
Utils for managing concurrent asyncio tasks.You can use theconcurrentasync generator to run asyncio tasks
concurrently.It works much likeasyncio.as_available, but with a couple of differences.coroscan be anyiterablesincluding sync/asyncgeneratorslimitcan be supplied to specify the maximum number of concurrent tasksSettinglimitto-1will make all tasks run concurrently.The defaultlimitisnumber of cores + 4to a maximum of32. This
(somewhat arbitrarily) reflects the default for asyncio’sThreadPoolExecutor.For network tasks it might make sense to set the concurrencylimitlower
than the default, if, for example, opening many concurrent connections will
trigger rate-limiting or soak bandwidth.If an error is raised while trying to iterate the provided coroutines, the
error is wrapped in anConcurrentIteratorErrorand is raised immediately.In this case, no further handling occurs, andyield_exceptionshas no
effect.Any errors raised while trying to create or run tasks are wrapped inConcurrentError.Any errors raised during task execution are wrapped inConcurrentExecutionError.If you specifyyield_exceptionsasTruethen the wrapped errors will be
yielded in the results.Ifyield_exceptionsis False (the default), then the wrapped error will
be raised immediately.If you use any kind ofGeneratororAsyncGeneratorto produce the
awaitables, andyield_exceptionsisFalse, in the event that an error
occurs, it is your responsibility tocloseremaining awaitables that you
might have created, but which have not already been fired.This utility is useful for concurrency of io-bound (as opposed to cpu-bound)
tasks.UsageLets first create a coroutine that waits for a random amount of time,
and then returns its id and how long it waited.>>>importrandom>>>asyncdeftask_to_run(task_id):...print(f"{task_id}starting")...wait=random.random()*5...awaitasyncio.sleep(wait)...returntask_id,waitNext lets create an async generator that yields 10 of the coroutines.Note that the coroutines are not awaited, they will be created as tasks.>>>defprovider():...fortask_idinrange(0,10):...yieldtask_to_run(task_id)Finally, lets create an function to asynchronously iterate the results, and
fire it with the generator.As we limit the concurrency to 3, the first 3 jobs start, and as the first
returns, the next one fires.This continues until all have completed.>>>importasyncio>>>fromaio.tasksimportconcurrent>>>asyncdefrun(coros):...asyncfor(task_id,wait)inconcurrent(coros,limit=3):...print(f"{task_id}waited{wait}")>>>asyncio.run(run(provider()))0 starting
1 starting
2 starting
... waited ...
3 starting
... waited ...
...
... waited ...
Package: aiotba
aiotbayet another wrapper for The Blue Alliance's API except this one usesasynciobecause it magically makes everything
faster, right?also because there's an overcomplicated type hinting system so there's autocomplete on everything (except for the season
specific data structures, those are all just dicts lol and nobody cares about themmostof the time)exampleimportasynciofromaiotbaimportTBASessionasyncdefmain():ses=TBASession("tba apiv3 key here")poofs=awaitses.team(254)print(poofs.nickname)asyncio.run(main())this lib follows closely to the endpoints ofAPIv3and should cover just
about all of them except for thesimpleendpointsinstallationpip install aiotbanotesall of this is on a provisional basis and large parts of the api could change at a moment's notice. this isn't "stable"
yet so to speak.
Package: aio-tcpserver
version: 0.0.3status: devauthor: hszemail:hsz1273327@gmail.comDescA tcp sever for runningasyncio.Protocol. The inspiration comes from sanic,only support python 3.6+keywords:tcp-server,asyncioFeaturewith multiple workerfor asyncio.Protocolcan be closed by ctrl+C in windowswith hooksExampleserver.pyimportasyncioimporttimefromaio_tcpserverimporttcp_server,listener@listener("before_server_start")asyncdefbeat(loop):print(time.time())print("ping")classEchoServerClientProtocol(asyncio.Protocol):defconnection_made(self,transport):peername=transport.get_extra_info('peername')print('Connection from{}'.format(peername))self.transport=transportdefdata_received(self,data):message=data.decode()print('Data received:{!r}'.format(message))print('Send:{!r}'.format(message))self.transport.write(data)print('Close the client socket')self.transport.close()defmain():tcp_server(EchoServerClientProtocol,worker=3)if__name__=='__main__':main()client.pyimportasyncioclassEchoClientProtocol(asyncio.Protocol):def__init__(self,message,loop):self.message=messageself.loop=loopdefconnection_made(self,transport):transport.write(self.message.encode())print('Data sent:{!r}'.format(self.message))defdata_received(self,data):print('Data received:{!r}'.format(data.decode()))defconnection_lost(self,exc):print('The server closed the connection')print('Stop the event loop')self.loop.stop()loop=asyncio.get_event_loop()message='Hello World!'coro=loop.create_connection(lambda:EchoClientProtocol(message,loop),'127.0.0.1',5000)loop.run_until_complete(coro)loop.run_forever()loop.close()Installpython-mpip installaio-tcpserverDocumentationDocumentation on Readthedocs.
Package: aiotelegraf
aiotelegrafAn asyncio-base client for sending metrics toTelegraf.Implementation based onpytelegrafpackage.Installation$pipinstallaiotelegrafUsageimportasyncioimportaiotelegrafasyncdefmain():client=aiotelegraf.Client(host='0.0.0.0',port=8089,tags={'my_global_tag_1':'value_1','my_global_tag_2':'value_2',})awaitclient.connect()client.metric('my_metric_1','value_1',tags={'my_tag_1':'value_1',})awaitclient.close()asyncio.run(main())ContributingTo work on theaiotelegrafcodebase, you'll want to clone the project locally and install the required dependencies viapoetry:$gitclonegit@github.com:Gr1N/aiotelegraf.git
$makeinstallTo run tests and linters use command below:$makelint&&maketestIf you want to run only tests or linters you can explicitly specify which test environment you want to run, e.g.:$makelint-blackLicenseaiotelegrafis licensed under the MIT license. See the license file for details.
Package: aiotelegram
Tiny asyncio-based telgram bot-api wrapper library.Reasonsaiotgis framework, not library and have no proxy support.Raw api calls translation is better for understanding and will not
break if telegram api will be changed.snake_caseFeaturesSimple as telegram api is.Works with any json provider (aiohttp(default),aiorequests, etc.)snake_caseapi converted to telegramcamelCase.Pollingoffsethandled for you viaget_updatesmethod.Handling timeout between requests automatically (viapausekeyword-only argument).Source code isshort and simple.Installationpython -m pip install aiotelegram
Package: aio-telegram-bot
aio-telegram-botAn asynchronous framework for building your own Telegram Bot overAPI.Installationaio-telegram-botrequires Python 3.5.3+ and is available on PyPI:$ pip install aio-telegram-bot*Compatible with PyPy3.5-6.0.0+ExamplesPolling exampleimportasyncioimportosfromaiotelegrambotimportBot,Client,Content,Messagefromaiotelegrambot.rulesimportContainsasyncdefhi(message:Message):awaitmessage.send_message("Hello!",True)asyncdefrun(bot:Bot):awaitbot.initialize()whileTrue:awaitasyncio.sleep(1)if__name__=="__main__":loop=asyncio.get_event_loop()client=Client(os.environ["TELEGRAM_BOT_TOKEN"])bot=Bot(client)bot.add_handler(hi,content_type=Content.TEXT,rule=Contains("hi"))try:loop.run_until_complete(run(bot))exceptKeyboardInterrupt:loop.run_until_complete(bot.close())loop.run_until_complete(bot.client.close())finally:loop.close()Running:$ export TELEGRAM_BOT_TOKEN=12345678:replace-me-with-real-token
$ python3 polling.pyWebhook exampleExample of how to generate ssl certificate:openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout domain_srv.key -out domain_srv.crtimportargparseimportjsonimportosimportsslfromaiohttpimportwebfromasync_generatorimportasync_generator,yield_fromaiotelegrambotimportBot,Client,Content,Handlers,Messagefromaiotelegrambot.rulesimportContainshandlers=Handlers()TOKEN=os.environ["TELEGRAM_BOT_TOKEN"]HOST=os.environ["TELEGRAM_BOT_HOST"]PORT=8443parser=argparse.ArgumentParser()parser.add_argument("files",metavar="N",type=str,nargs="+")SSL_PUBLIC_KEY,SSL_PRIVATE_KEY=parser.parse_args().files@handlers.add(content_type=Content.TEXT,rule=Contains("hi"))asyncdefhi(message:Message):awaitmessage.send_message("Hello!")asyncdefwebhook_handle(request):bot=request.app["bot"]data=awaitrequest.text()awaitbot.process_update(json.loads(data))returnweb.Response()@async_generatorasyncdefinit_bot(app:web.Application):bot=Bot(Client(TOKEN),handlers)awaitbot.initialize(webhook=True)awaitbot.client.set_webhook("https://{}:{}/{}".format(HOST,PORT,TOKEN),certificate=SSL_PUBLIC_KEY)app["bot"]=botawaityield_()awaitbot.client.delete_webhook()awaitbot.close()awaitbot.client.close()app=web.Application()app.router.add_post("/{}".format(TOKEN),webhook_handle)app.cleanup_ctx.extend([init_bot])context=ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)context.load_cert_chain(SSL_PUBLIC_KEY,SSL_PRIVATE_KEY)web.run_app(app,host="0.0.0.0",port=PORT,ssl_context=context)Running:$ export TELEGRAM_BOT_TOKEN=12345678:replace-me-with-real-token
$ export TELEGRAM_BOT_HOST=real.host.com
$ python3 webhook.py domain_srv.crt domain_srv.keyLicenseaio-telegram-botis offered under the MIT license.
Package: aio-telegram-log-handler
Aio-telegram-logBasic library for sending log to telegram, using python logging module(like handler), but do it asynchronously.UsageJust set telegram handler in your logging settings...
"handlers": {
    "default": {
        "formatter": "default",
        "level": "DEBUG",
        "class": "logging.StreamHandler",
        "stream": "ext://sys.stdout",
    },
    "telegram": {
        "class": "tghandler.handler.TelegramLoggingHandler",
        "token": "input your token",
        "chat_ids": [0, 1],
        "level": "ERROR",
        "formatter": "default",
    },
},
...
Package: aiotelegraph
aiotelegraphDescriptionThis is simple async library for interaction with Telegra.ph APIContentsRelease Notes0.1.0Getting StartedInstallation from PipInstallation from GitHubQuick StartUser GuideDocumentationEntitiesMethodsHelp the authorContribute repoDonateRelease NotesVersion 0.1.0Init libraryGetting StartedInstallation from pipFor installation aiotelegraph library from pip you should have pip with python (prefer python3.6 or
later)pipinstallaiotelegraphInstallation from GitHubTo basic installation from GitHub repository you should have git, python3 (prefer python3.6 or
later), pip (optionally) in your systemgitclonehttps://github.com/OlegYurchik/aiotelegraph.gitcdaiotelegraph
pipinstall.orgitclonehttps://github.com/OlegYurchik/aiotelegraph.gitcdaiotelegraph
pythonsetup.pyinstallQuick StartAfter installation, you can use the library in your code. Below is a sneak example of using the
library.fromasynciofromaiotelegraphimportNodeElement,TelegraphClientasyncdefmain():client=TelegraphClient()awaitclient.create_account(short_name="ShortName",author_name="AuthorName",author_url="AuthorUrl")content=[NodeElement(text="Hello"),NodeElement(text="Neighbour"),]page=awaitclient.create_page(title="Greeting",content=content,return_content=True)loop=asyncio.get_event_loop()loop.run_until_complete(main())
Package: aiotempfile
aiotempfileOverviewProvides asynchronous temporary files.InstallationFrompypi.org$ pip install aiotempfileFrom source code$gitclonehttps://github.com/crashvb/aiotempfile
$cdaiotempfile
$virtualenvenv
$sourceenv/bin/activate
$python-mpipinstall--editable.[dev]UsageThis implementation is a derivation ofaiofilesand functions the same way.importaiotempfileasyncwithaiotempfile.open()asfile:file.write(b"data")If the context manager is not used, files will need be explicitly closed; otherwise, they will only be removed during the interepreter teardown.importaiotempfilefile=awaitaiotempfile.open()file.write(b"data")file.close()Environment VariablesVariableDefault ValueDescriptionAIOTEMPFILE_DEBUGAdds additional debug logging.DevelopmentSource Control
Package: aiotestspeed
AIO Speedtestis a library written in Python to perform speed tests asynchronously and programmatically.This project was made based on the existingSpeedtestfrom which we shared several code snippets, what I did were few modifications to work asynchronously.Basic Usageimport asyncio
from aiotestspeed.aio import Speedtest

units = ('bit', 1)

async def main():
    s: Speedtest = await Speedtest()
    await s.get_best_server()
    await s.download()
    await s.upload()
    print('Ping: %s ms\nDownload: %0.2f M%s/s\nUpload: %0.2f M%s/s' %
          (s.results.ping,
          (s.results.download / 1000.0 / 1000.0) / units[1],
          units[0],
          (s.results.upload / 1000.0 / 1000.0) / units[1],
          units[0]))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()class Speedtest(aiobject):

    async def __init__(self, config=None, source_address=None, timeout=10, secure=False):
        ...

    @property
    async def best(self) -> dict:
        ...

    async def get_config(self) -> dict:
        """Download the speedtest.net configuration and return only the data
        we are interested in
        """
        ...

    async def get_servers(self, servers: list = None, exclude: list = None) -> list:
        """Retrieve a the list of speedtest.net servers, optionally filtered
        to servers matching those specified in the ``servers`` argument
        """
        ...

    async def set_mini_server(self, server: str) -> list:
        """Instead of querying for a list of servers, set a link to a
        speedtest mini server
        """
        ...

    async def get_closest_servers(self, limit: int = 5) -> None:
        """Limit servers to the closest speedtest.net servers based on
        geographic distance.
        """
        ...

    async def get_best_server(self, servers=None) -> dict:
        """Perform a speedtest.net "ping" to determine which speedtest.net
        server has the lowest latency.

        Args:
            servers ([type], optional): [description]. Defaults to None.

        Raises:
            SpeedtestBestServerFailure: [description]

        Returns:
            dict: [description]
        """
        ...

    async def download(self, callback=do_nothing) -> int:
        """Test download speed against speedtest.net

        Args:
            callback ([type], optional): [description]. Defaults to do_nothing.

        Returns:
            int: [description]
        """
        ...

    async def upload(self, callback=do_nothing, pre_allocate: bool = True) -> int:
        """Test upload speed against speedtest.net

        Args:
            callback ([type], optional): [description]. Defaults to do_nothing.
            pre_allocate (bool, optional): [description]. Defaults to True.

        Returns:
            int: [description]
        """
        ...Changelog
Package: aiotf
aiotfAsyncio-basedTensorflow ServingPredictionFeaturesasyncio:better use of your cpu idle timepep8 compliant:following best code standardshigh-performance prediction:we useaio-grpcExampleimportaiotfasyncdefmake_prediction(model_name:str,data):asyncwithaiotf.AsyncTensorflowServing('localhost:9000')asclient:predictions=awaitclient.predict(model_name,data)You can find more examples in theexamples/subdirectory.Installation$pipinstallaiotfLicenseMIT
Package: aiotfm
aiotfmaiotfm is an asynchronous Client implementation ofTransformicethat allows developers to make bots easily.
It uses an API endpoint to get the keys needed to connect to the game.
aiotfm is based onTransFromagewhich use threads instead of coroutines.If you prefer Lua over Python then checkout theLua versionmade by@Lautenschlager-idJoin theFifty Shades of Luadiscordserver to discuss about this API and to receive special support.Keys EndpointThis API depends on anendpointthat gives you access to the Transformice encryption keys.To use it you will need a token which you can get byapplying through this form. See below to know the names of Transfromage managers who handle the token system.Tocutoeltuco@discord=>Tocu#0018212634414021214209;Blank3495@discord=>󠂪󠂪 󠂪󠂪 󠂪󠂪󠂪󠂪 󠂪󠂪 󠂪󠂪󠂪󠂪 󠂪󠂪 󠂪󠂪#8737436703225140346881;Bolodefchoco@discord=>Lautenschlager#2555285878295759814656.Advantages3 times faster than TransFromageCompatible with discord.pyFasterAsynchronousSpeedTransFromage takes around 13 seconds to be connected to the community platform while aiotfm takes less than 4 seconds.
Those results can vary depending on your computer and your internet connection.InstallationYou can install aiotfm using pip:pip install aiotfmTo have a more up to date package, you have to clone this repository and install it manually:gitclonehttps://github.com/Athesdrake/aiotfmcdaiotfm
python3-mpipinstall.Requirementsaiotfm require python 3.7 or higher andaiohttp.Python 3.6Python 3.6 support is not guaranteed sincev1.4.3as Python 3.6 has reached EOF.Python 3.5You can still use aiotfm with Python 3.5.3 or higher by cloning the repository and remove the sugar syntax of Python 3.6.
These changes are the typed variables and fstrings.
Due to a major update in the asynchronous stuff of Python 3.5.3, aiotfm is not compatible with the previous versions of Python.UpdateTo update aiotfm, use the following command:pip install -U aiotfmExampleimportaiotfmbot=aiotfm.Client()@bot.eventasyncdefon_ready():print('Connected to the community platform.')bot.run("api_tfmid","api_token","username","password",encrypted=False,room="start_room")A more complete example.DocumentationYou can find the documentation of aiotfmhere.AboutYou can have more information about TransFromage in thisthread.
Package: aiotg
Asynchronous Python API for building Telegram bots, featuring:Easy and declarative APIHassle-free setup - no need for SSL certificates or static IPBuilt-in support for analytics via chatbase.comAutomatic handling of Telegram API throttling or timeoutsInstall it with pip:pipinstallaiotgThen you can create a new bot in few lines:fromaiotgimportBot,Chatbot=Bot(api_token="...")@bot.command(r"/echo (.+)")defecho(chat:Chat,match):returnchat.reply(match.group(1))bot.run()Now run it with a proper API_TOKEN and it should reply to /echo commands.NoteType annotations are not required but will help your editor/IDE to provide code completion.The example above looks like a normal synchronous code but it actually returns a coroutine.
If you want to make an external request (and that’s what bots usually do) just use aiohttp and async/await syntax:importaiohttpfromaiotgimportBot,Chatbot=Bot(api_token="...")@bot.command("bitcoin")asyncdefbitcoin(chat:Chat,match):url="https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD"asyncwithaiohttp.ClientSession()assession:response=awaitsession.get(url)info=awaitresponse.json()awaitchat.send_text(str(info["averages"]["day"]))bot.run()But what if you just want to write a quick integration and don’t need to provide a conversational interface? We’ve got you covered!
You can send messages (or any other media) by constructing a Chat object with user_id or channel name. We even saved you some extra keystrokes by providing handy Channel constructors:...channel=bot.channel("@yourchannel")private=bot.private("1111111")asyncdefgreeter():awaitchannel.send_text("Hello from channel!")awaitprivate.send_text("Why not greet personally?")...ExamplesAsync IOSend imagePost to channelWebhooks modeSender idFor a real world example, take a look atWhatisBotorMusic Catalog Bot.For more information on how to use the project, see the project’sdocumentation.