Saravanan666/pypi-org huggingface dataset:
Package: asyncio-dgram
Higher level Datagram support for AsyncioSimple wrappers that allow you toawait read()from datagrams as suggested
by Guido van Rossumhere.  I
frequently found myself having to inherit fromasyncio.DatagramProtocoland
implement this over and over.DesignThe goal of this package is to make implementing common patterns that use datagrams
simple and straight-forward while still supporting more esoteric options.  This is done
by taking an opinionated stance on the API that differs from parts of asyncio.  For instance,
rather than exposing a function likecreate_datagram_endpointwhich supports many use-cases and has conflicting parameters,asyncio_dgramonly provides three functions for creating a stream:connect((host, port)): Creates a datagram endpoint which can only
communicate with the endpoint it connected to.bind((host, port)): Creates a datagram endpoint that can communicate
with anyone, but must specified the destination address every time it
sends.from_socket(sock): If the above two functions are not sufficient, thenasyncio_dgramsimply lets the caller setup the socket as they see fit.Example UDP echo client and serverFollowing the example of asyncio documentation, here's what a UDP echo client
and server would look like.importasyncioimportasyncio_dgramasyncdefudp_echo_client():stream=awaitasyncio_dgram.connect(("127.0.0.1",8888))awaitstream.send(b"Hello World!")data,remote_addr=awaitstream.recv()print(f"Client received:{data.decode()!r}")stream.close()asyncdefudp_echo_server():stream=awaitasyncio_dgram.bind(("127.0.0.1",8888))print(f"Serving on{stream.sockname}")data,remote_addr=awaitstream.recv()print(f"Echoing{data.decode()!r}")awaitstream.send(data,remote_addr)awaitasyncio.sleep(0.5)print(f"Shutting down server")defmain():loop=asyncio.get_event_loop()loop.run_until_complete(asyncio.gather(udp_echo_server(),udp_echo_client()))if__name__=="__main__":main()
Package: asyncio_dispatch
asyncio_dispatchis a is a signal dispatcher for theasyncioevent loop found in Python versions 3.4 and up.Check out theofficial documentationSynopsisMany callbacks can be connected to a Signal. When the Signal is triggered using itssend()method, all connected callbacks will be scheduled for asynchronous execution.Connections can optionally be made with two types of filters,sendersandkeys. If filters are used, the callback is only scheduled for execution if the Signal is sent with at least one matchingsenderorkey. Asendercan be any object, while akeyis more likely to be astring. Under the hood, they useid()andhash()respectively.Callbacks are invoked with keyword arguments that allow the callback to determine which Signal is calling it and whichsendersandkeyswere specified. Additional keyword arguments can be added to the Signal when it is instantiated, and their default values can be replaced when the Signal is sent.Exampleimportasynciofromasyncio_dispatchimportSignal@asyncio.coroutinedefcallback(**kwargs):print('callback was called!')loop=asyncio.get_event_loop()# create the signalsignal=Signal(loop=loop)# connect the callback to the Signal - This is a coroutine!loop.run_until_complete(loop.create_task(signal.connect(callback)))# send the signal - This is also a coroutine!print('sending the signal.')loop.run_until_complete(loop.create_task(signal.send()))The above example will print the following:sendingthesignal.callbackwascalled!FeaturesSupports the new async/await syntax found in python 3.5 and upCallbacks can be a function, asyncio.coroutine, async def, class method, @staticmethod, or @classmethodMultiple callbacks can be connected to the same signalCallbacks can be called with additional keyword arguments containing references to arbitrary objectsCallbacks can be disconnected from a signalSignals can hold weak or strong references to callbacks, allowing for automatic disconnection if a reference to a callback is not maintained, or conversely to persist one-offlambdaexpressions without needing to maintain a referenceCallbacks receive theSignalobject that was used to schedule it, so multiple signals can be attached to the same callback and handled differentlyCallbacks can be connected withsendersorkeyswhich cause the Signal to ignore the callback unless the signal is sent with a matchingObjectorstrLicenseReleased under the MIT license.Installationpipinstallasyncio_dispatch
Package: asyncio-event-hub
Asyncio Event Hub is a library that provides users with a way to easily create
event-driven applications within the asyncio framework. It provides one main classasyncio_event_hub.controller.EventController, which can be used to emit events and add listeners (functions) to events
that get called from the event loop in the same order they were added.Installationpipinstallasyncio-event-hubExampleimportasyncio_event_hubasaehimportasyncio# Create event controllersmain_controller=aeh.EventController()sub_controller=aeh.EventController()# Register sub_controller as a sub-controller of the main_controllermain_controller.add_subcontroller(sub_controller)# Add listener via a decorator@main_controller.listen("my_event")asyncdeflistener1(a,b):print(f"listener1({a},{b})")# Add listeners via a decorator@main_controller.listen("my_event")@sub_controller.listen("my_event")deflistener2(a,b):print(f"listener2({a},{b})")asyncdefstop(a):main_controller.stop()# Stop main_controller and it's sub-controllers.# Add listener through functionmain_controller.add_listener("stop_event",stop,predicate=lambdaa:a==5)# Only call stop(a) if a is equal to 5asyncdefmain():main_controller.start()# Start main_controller and it's sub-controllers.# Emit events into the event loop, executed asynchronously.# listener1 is called once, listener2 is caller twice -# once from main controller's event loop and once sub-controller's event loop. (not at this line, but asynchronously)main_controller.emit("my_event",a=9,b=10)# listener2 is called once from sub-controller's event loop. (not at this line, but asynchronously)sub_controller.emit("my_event",a=1,b=2)# await used to await for all listeners to finish processing event.awaitmain_controller.emit("stop_event",a=1)# Does not actually call anything since we have a predicate of a == 5.awaitmain_controller.emit("stop_event",a=5)# Stops controller asynchronouslyasyncio.run(main())
Package: asyncio-events
Events-asyncioThis is a modification ofEvents library_ that adds support for asyncio.
Unlike the original library, this modification only supports Python 3.5+.The C# language provides a handy way to declare, subscribe to and fire events.
Technically, an event is a "slot" where callback functions (event handlers) can
be attached to - a process referred to as subscribing to an event. Here is
a handy package that encapsulates the core to event subscription and event
firing and feels like a "natural" part of the language... code-block:: pycon>>> async def something_changed(reason):
...     await some_awaitable()
...     print "something changed because %s" % reason
...

>>> from events import Events
>>> events = Events()
>>> events.on_change += something_changedMultiple callback functions can subscribe to the same event. When the event is
fired, all attached event handlers are invoked in sequence. To fire the event,
perform a call on the slot:.. code-block:: pycon>>> await events.on_change('it had to happen')
'something changed because it had to happen'By default, Events does not check if an event can be subscribed to and fired.
You can predefine events by subclassing Events and listing them. Attempts to
subscribe to or fire an undefined event will raise an EventsException... code-block:: pycon>>> class MyEvents(Events):
...     __events__ = ('on_this', 'on_that', )

>>> events = MyEvents()

# this will raise an EventsException as `on_change` is unknown to MyEvents:
>>> events.on_change += something_changedYou can also predefine events for a single Events instance by passing an iterator to the constructor... code-block:: pycon>>> events = Events(('on_this', 'on_that'))

# this will raise an EventsException as `on_change` is unknown to events:
>>> events.on_change += something_changedInstallingEvents is on PyPI so all you need to do is: ::pip install asyncio-eventsTestingJust run: ::python setup.py testLicenseAsyncio-events is BSD licensed. See the LICENSE_ for details.AttributionBased on Events library byNicola Iarocci... _LICENSE:https://github.com/pyeve/events/blob/master/LICENSE.. _Zoran Isailovski:http://code.activestate.com/recipes/410686/.. _Nicola Iarocci:https://github.com/nicolaiarocci.. _Events Library:https://github.com/pyeve/events
Package: asyncio-executor
version: 0.0.4status: devauthor: hszemail:hsz1273327@gmail.comDescAsyncio executor for running coroutines. This code is from <https://gist.github.com/seglberg/0b4487b57b4fd425c56ad72aba9971be>keywords:asyncio,executorFeaturerun coroutines asynchronouslyExamplerun coroutines by usingsubmitfromconcurrent.futuresimportas_completedimportaiohttpfromasyncio_executorimportAsyncioExecutorasyncdefhttpget(url):asyncwithaiohttp.ClientSession()assession:asyncwithsession.get(url)asresp:html=awaitresp.text("utf-8")returnlen(html)withAsyncioExecutor()asexecutor:to_do=[]urls=["https://github.com/","https://docs.aiohttp.org/"]foriinurls:job=executor.submit(httpget,i)to_do.append(job)forfutureinas_completed(to_do):res=future.result()run coroutines by using mapfromconcurrent.futuresimportas_completedimportaiohttpfromasyncio_executorimportAsyncioExecutorasyncdefhttpget(url):asyncwithaiohttp.ClientSession()assession:asyncwithsession.get(url)asresp:html=awaitresp.text("utf-8")returnlen(html)withAsyncioExecutor()asexecutor:result=[]urls=["https://github.com/","https://docs.aiohttp.org/"]foriinexecutor.map(httpget,urls):result.append(i)run functions by using submitfromconcurrent.futuresimportas_completedimportrequestsasrqfromasyncio_executorimportAsyncioExecutordefhttpsync(url):req=rq.get(url)returnlen(req.text)withAsyncioExecutor()asexecutor:to_do=[]urls=["https://github.com/","https://docs.aiohttp.org/"]foriinurls:job=executor.submit(httpsync,i)to_do.append(job)forfutureinas_completed(to_do):res=future.result()print(res)run functions by using mapfromconcurrent.futuresimportas_completedimportrequestsasrqfromasyncio_executorimportAsyncioExecutordefhttpsync(url):req=rq.get(url)returnlen(req.text)withAsyncioExecutor()asexecutor:result=[]urls=["https://github.com/","https://docs.aiohttp.org/"]foriinexecutor.map(httpsync,urls):result.append(i)print(result)Installpython-mpip installasyncio-executorLimitationsonly support python 3.5+
Package: asyncio-fast-portscanner
asyncio-fast-portscannerGet your active host list in N * timeout fixed timeFree software: MIT licenseDocumentation:https://asyncio-fast-portscanner.readthedocs.io.FeaturesScan specific ports for specific hosts with fixed timeoutHistory0.0.2 (2019-10-19)Fixed cli version.0.0.1 (2019-10-19)First release on PyPI.
Package: asyncio-gcloud-ml-engine
asyncio-gcloud-ml-engineAsyncio-basedGoogle Cloud Machine Learning EnginePrediction & TrainingFeaturesasyncio:better use of your cpu idle timepep8 compliant:following best code standardstests:full tested to keep up-to-date on socketclusterhigh-performance prediction:we try to useaio-grpcwhen possibleExamplefromasyncio_ml_engineimportMachineLearningClientproject='my-gcloud-project'service_account='./myserviceaccount.json'asyncdefmyfunc():asyncwithMachineLearningClient(project,service_account)asclient:prediction=awaitclient.predict('mymodel',X)You can find more examples in theexamples/subdirectory.Installation$pipinstallasyncio-gcloud-ml-engineLicenseMIT
Package: asyncio-glib
GLib event loop integration for asyncioThis module provides a Python 3asyncioevent loop implementation
that makes use of theGLib event loop.  This allows for mixing of
asyncio and some GLib based code within the same thread.Enabling this event loop can be achieved with the following code:import asyncio
import asyncio_glib
asyncio.set_event_loop_policy(asyncio_glib.GLibEventLoopPolicy())At this point,asyncio.get_event_loop()will return aGLibEventLoop.Implementation strategyTo ease maintenance, I have tried to reuse as much of the standard
library asyncio code as possible.  To this end, I created a GLib
implementation of theselectors.BaseSelectorAPI.  Combine this
with the existingasyncio.SelectorEventLoopclass, and we have our
event loop implementation.To test that the event loop is functional, I have reused parts of the
standard library test suite to run against the new selector and event
loop.At present the selector sublcasses the privateselectors._BaseSelectorImplclass, which is a potential source of
future compatibility problems.  If that happens, taking a local copy
of that code is an option.Comparison with GbulbGbulbis another implementation of the asyncio event loop on top
of GLib.  The main differences are:Gbulb dispatches asyncio callbacks directly from the GLib main
loop.  In contrast, asyncio-glib iterates the GLib main loop until
an asyncio event is ready and then has asyncio event loop dispatch
the event.Gbulb has some Windows compatibility code, while asyncio-glib has
had no testing on that platform.asyncio-glib is an essentially unmodifiedSelectorEventLoop, so
should automatically gain any features from new Python releases.The asyncio-glib code base is also about one tenth of the size of Gbulb.
Package: asyncio-gpsd-client
Asycio Gpsd ClientInstallpipinstallasyncio-gpsd-clientUsageimportasynciofromasyncio_gpsd_clientimportGpsdClientHOST="127.0.0.1"PORT=2947asyncdefmain():asyncwithGpsdClient(HOST,PORT)asclient:print(awaitclient.poll())# Get gpsd POLL responsewhileTrue:print(awaitclient.get_result())# Get gpsd TPV responsesasyncio.run(main())
Package: asyncio-guard
Guard that provide exclusive access to an objectPython 3.7 or higher.Install: pip install asyncio-guardExamples of usage:Set a value, get exclusive access to it, set another valueguard=Guard(obj=1)asyncwithguardasobj:assertobj==1awaitguard.set(2)asyncwithguardasobj:assertobj==2Update a value by using update function.This update function will be used, if no value was set up.guard=Guard(obj=1,update_func=lambda:return2)asyncwithguardasobj:assertobj==1awaitguard.update_func()asyncwithguardasobj:assertobj==2
Package: asyncio-helpers
asyncio-helpers- utilities for asyncio. Also comes withpacoInstallationasyncio-helpersis listed onPyPIand can be installed with pip:pipinstallasyncio-helpersLicenseThis project is licensed under theMIT License.MIT License

Copyright (c) 2019 Niranjan Rajendran

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Package: asyncio_hn
asyncio-hn==========A simple asyncio wrapper to download`hacker-news <https://news.ycombinator.com/>`__ with speed and ease.The package supports all endpoints of the official API : `hacker-newsAPI <https://github.com/HackerNews/API>`__Installation------------.. code:: shellpip install asyncio-hnUsage-----.. code:: pythonimport asynciofrom asyncio_hn import ClientHNasync def main(loop):# We init the client - extension of aiohttp.ClientSessionasync with ClientHN(loop=loop) as hn:# Up to 500 top and top stories (only ids)hn_new_stories = await hn.top_stories()# Download top 10 story datatop_posts = await hn.items(hn_new_stories[:10])# Download the user data for each storyusers = await hn.users([post.get("by") for post in top_posts])if __name__ == '__main__':loop = asyncio.get_event_loop()loop.run_until_complete(main(loop))Advance usage~~~~~~~~~~~~~Using this config you can reach 1000+ request/sec... code:: pythonimport aiohttpfrom asyncio_hn import ClientHNN = 1_000_000async def advance_run(loop):# We init the client - extension of aiohttp.ClientSessionconn = aiohttp.TCPConnector(limit=1000, loop=loop)async with ClientHN(loop=loop, queue_size=1000, connector=conn, progress_bar=True, debug=True) as hn:# Download the last 1,000,000 storieshn_new_stories = await hn.last_n_items(n=N)Output example:---------------Item:.. code:: pythonitem = {'by': 'amzans', 'descendants': 25, 'id': 13566716,'kids': [13567061, 13567631, 13567027, 13567055, 13566798, 13567473], 'score': 171, 'time': 1486210548,'title': 'Network programming with Go (2012)', 'type': 'story','url': 'https://jannewmarch.gitbooks.io/network-programming-with-go-golang-/content/'},{'by': 'r3bl', 'descendants': 1, 'id': 13567940, 'kids': [13568249], 'score': 24, 'time': 1486230224,'title': 'YouTube removes hundreds of the best climate science videos from the Internet','type': 'story','url': 'http://climatestate.com/2017/02/03/youtube-removes-hundreds-of-the-best-climate-science-videos-from-the-internet/'}User:.. code:: pythonuser = {'created': 1470758993, 'id': 'amzans', 'karma': 174,'submitted': [13567884, 13566716, 13566699, 13558456, 13539270, 13539151, 13514498, 13418469, 13417725,13416562, 13416097, 13416034, 13415954, 13415894, 13395310, 13394996, 13392554, 12418804,12418361, 12413958, 12411992, 12411732, 12411546, 12262383, 12255593]}
Package: asyncio-inspector
asyncio_inspectorCrazily simple statistics tracker for asyncio event loops, for the moments when just setting the event loop to debug mode is not enough.This package is meant to be used to track basic statistics about asyncio event loops, so you can easily see which methods are blocking the event loop for longer, preventing other tasks from running.Install it from PyPIpipinstallasyncio_inspectorUsageEnable inspection on any given event loop with theinspect(event_loop)anduninspect(event_loop)methods:fromasyncio_inspectorimportinspect,uninspectloop=asyncio.get_event_loop()stats_tracker=inspect(loop)loop.call_soon(my_async_function)loop.call_soon(another_async_function)loop.call_soon(loop.stop)uninspect(loop)Or with a context manager:loop=asyncio.get_event_loop()withenable_inpection(loop)asstats_tracker:awaitmy_async_function()awaitanother_async_function()Then, you will have some statistics in the stats_tracker object:stats_tracker.call_counts=={"my_async_function":1,"another_async_function":1}# Times are in nanosecsstats_tracker.total_time=={"my_async_function":123,"another_async_function":333}stats_tracker.max_time=={"my_async_function":400,"another_async_function":500}stats_tracker.min_time=={"my_async_function":100,"another_async_function":200}DevelopmentRead theCONTRIBUTING.mdfile.
Package: asyncio-ipython-magic
An extension forIPythonthat help to run
AsyncIO code in your interactive session.Based onGist.InstallationInstallasyncio-ipython-magicusingpip:$ pip install asyncio-ipython-magic…or directly from the repository using the%install_extmagic
command:$ In[1]: %install_ext https://raw.githubusercontent.com/Gr1N/asyncio-ipython-magic/master/asynciomagic.pyEnjoy!UsageIn [1]: %load_ext asynciomagic

In [2]: import asyncio

In [3]: import time

In [4]: async def foo():
   ...:     i = 0
   ...:     while i < 3:
   ...:         print('time =', time.time())
   ...:         i += 1
   ...:         await asyncio.sleep(2)
   ...:

In [5]: %%async_
   ...: await foo()
   ...:
time = 1478985421.307329
time = 1478985423.309606
time = 1478985425.31514

In [6]: %await_ foo()
time = 1487097377.700184
time = 1487097379.705614
time = 1487097381.707186

In [7]:TestingIt just works, I hope.Licenseasyncio-ipython-magicis licensed under the MIT license. See the
license file for details.
Package: asynciolimiter
asynciolimiterA simple yet efficient Python AsyncIO rate limiter.Installationpip install asynciolimiterSample Usage# Limit to 10 requests per 5 second (equiv to 2 requests per second)>>>limiter=asynciolimiter.Limiter(10/5)>>>asyncdefmain():...awaitlimiter.wait()# Wait for a slot to be available....pass# do stuff>>>limiter=Limiter(1/3)>>>asyncdefrequest():...awaitlimiter.wait()...print("Request")# Do stuff...>>>asyncdefmain():...# Schedule 1 request every 3 seconds....awaitasyncio.gather(*(request()for_inrange(10)))Available Limiter flavorsLimiter: Limits by requests per second and takes into account CPU heavy
tasks or other delays that can occur while the process is sleeping.LeakyBucketLimiter: Limits by requests per second according to theleaky bucket algorithm. Has a maximum capacity and an initial burst of
requests.StrictLimiter: Limits by requests per second, without taking CPU or other
process sleeps into account. There are no bursts and the resulting rate will
always be a less than the set limit.DocumentationFull documentation available onRead the Docs.LicenseLicensed under the MIT License.
Package: asyncio_monkey
asyncio_monkey==============:info: monkey patch asyncio modules for expected behaviour.. image:: https://img.shields.io/travis/wikibusiness/asyncio_monkey.svg:target: https://travis-ci.org/wikibusiness/asyncio_monkey.. image:: https://img.shields.io/pypi/v/asyncio_monkey.svg:target: https://pypi.python.org/pypi/asyncio_monkeyInstallation------------.. code-block:: shellpip install asyncio_monkeyUsage-----.. code-block:: python# it must be done before any import asyncio statement, once per project# best place is __init__.py of You'r applicationfrom asyncio_monkey import patch_all  # noqa isort:skippatch_all()or call the one you need.. code-block:: python# it must be done before any import asyncio statement, once per project# best place is __init__.py of You'r applicationimport asyncio_monkey  # noqa isort:skipasyncio_monkey.patch_gather()asyncio_monkey.patch_log_destroy_pending()asyncio_monkey.patch_get_event_loop()asyncio_monkey.patch_lock()Features--------- Cancel pending tasks `gather` if any task fails, `source <https://bugs.python.org/issue31452>`_- Disables `get_event_loop` returns currently running loop, even if `MainThread` loop is `None`, `docs <https://docs.python.org/3/library/asyncio-eventloops.html#asyncio.get_event_loop>`_ , `source <https://bugs.python.org/issue28613>`_- Disables silent destroying futures inside `asyncio.gather` `source <https://github.com/python/cpython/blob/3dc7c52a9f4fb83be3e26e31e2c7cd9dc1cb41a2/Lib/asyncio/tasks.py#L600>`_- Prevents `asyncio.Lock` deadlock after cancellation  `source <http://bugs.python.org/issue27585>`_