Saravanan666/pypi-org huggingface dataset:
Package: asyncimg
asyncimgAn async image manipulation lib. Can be used for discord.UsagefromasyncimgimportGeneratorgenerator=Generator()image=awaitgenerator.lovers(profile_pic_link1,profile_pic_link2)# In discord commandfile=discord.File(fp=image,filename='image.png')awaitctx.send(file=file)Available methodslovers(profile_pic_link1,profile_pic_link2)stars(profile_pic_link)colors(profile_pic_link)frame(profile_pic_link)envelop(profile_pic_link)knockout(profile_pic_link1,profile_pic_link2)fart(profile_pic_link)More coming soonAny help need or better suggesions?Join hereto contribute.Change Log0.0.1 (3/8/2020)Release (Buggy)1.0.0 (3/8/2020)Working release1.0.1 (3/8/2020)Attempt to fix frame (Images do not match)
Package: asyncinit
asyncinit -- Enable async__init__DocumentationThis package provides theasyncinitdecorator, which enables an asynchronous constructor
to be called like any other asynchronous function.Examplefromasyncinitimportasyncinit@asyncinitclassMyClass:asyncdef__init__(self,param):self.val=awaitself.deferredFn(param)asyncdefdeferredFn(self,x):# ...returnx+2obj=awaitMyClass(42)assertobj.val==44InstallationThis package requires Python >= 3.5.0 and can be installed withpip:pip install asyncinit
Package: asyncinotify
An async python inotify package.  Kept as simple and easy-to-understand as
possible, while still being flexible and powerful.  This is built on no external
dependencies, and works through ctypes in a very obvious fashion.This depends on Python 3.6+ features, and will not work with prior versions.This works without any other external dependencies.The code is available onGitHuband the documentation is available onReadTheDocs. The package itself is available onPyPi.InstallationYou know the drill:pip install asyncinotifyUsageThe core of this package isasyncinotify.Inotify.  Most important
Classes may be imported directly from theasyncinotifypackage.frompathlibimportPathfromasyncinotifyimportInotify,Maskimportasyncioasyncdefmain():# Context manager to close the inotify handle after usewithInotify()asinotify:# Adding the watch can also be done outside of the context manager.# __enter__ doesn't actually do anything except return self.# This returns an asyncinotify.inotify.Watch instanceinotify.add_watch('/tmp',Mask.ACCESS|Mask.MODIFY|Mask.OPEN|Mask.CREATE|Mask.DELETE|Mask.ATTRIB|Mask.CLOSE|Mask.MOVE|Mask.ONLYDIR)# Iterate events forever, yielding them one at a timeasyncforeventininotify:# Events have a helpful __repr__.  They also have a reference to# their Watch instance.print(event)# the contained path may or may not be valid UTF-8.  See the note# belowprint(repr(event.path))asyncio.run(main())This will asynchronously watch the /tmp directory and report events it
encounters.This library also supports synchronous operation, using theasyncinotify.inotify.Inotify.sync_get`method, or simply using
synchronous iteration.MotivationThere are a few different python inotify packages.  Most of them either have odd
conventions, expose too much of the underlying C API in a way that I personally
don’t like, are badly documented, they work with paths in a non-idiomatic way,
are not asynchronous, or are overengineered compared to the API they are
wrapping.  I find that the last one is true for the majority of them.I encourage everybody to read thesourcesof this package.  They are
quite simple and easy to understand.This libraryWorks in a very simple way.  It does not have add-ons or extra features beyond
presenting a very Python interface to the raw inotify functionality.Grabs events in bulk and caches them for minor performance gains.Leverages IntFlag for all masks and flags, allowing the user to use the
features of IntFlag, such as seeing individual applied flags in therepr,
checking for flag set bits within.Exposes all paths via python’spathlibExposes all the functionality of inotify without depending on the user having
to interact with any of the underlying mechanics of Inotify.  You should never
have to touch the inotify or watch descriptors for any reason.The primary motivation is that this is written to be a Python inotify module
that I would feel comfortable using.
Package: async-interrupt
async_interruptInterrupt context manager for asyncio.This module provides a context manager that can be used to interrupt
a block of code as soon as possible when a future is done.The purpose is to raise as soon as possible to avoid any race conditions.This is based loosely on async_timeout by Andrew Svetlov and cpython asyncio.timeoutUsageasyncwithinterrupt(future,ValueError,"message"):future.set_result(None)awaitasyncio.sleep(0)InstallationInstall this via pip (or your favourite package manager):pip install async_interruptContributors ✨Thanks goes to these wonderful people (emoji key):This project follows theall-contributorsspecification. Contributions of any kind welcome!CreditsThis package was created withCopierand thebrowniebroke/pypackage-templateproject template.
Package: asyncio
This version is only relevant for Python 3.3, which does not include asyncio in its stdlib.Master repo:https://github.com/python/asyncioThe asyncio module provides infrastructure for writing single-threaded
concurrent code using coroutines, multiplexing I/O access over sockets and
other resources, running network clients and servers, and other related
primitives.  Here is a more detailed list of the package contents:a pluggable event loop with various system-specific implementations;transport and protocol abstractions (similar to those in Twisted);concrete support for TCP, UDP, SSL, subprocess pipes, delayed calls, and
others (some may be system-dependent);a Future class that mimics the one in the concurrent.futures module, but
adapted for use with the event loop;coroutines and tasks based onyield from(PEP 380), to help write
concurrent code in a sequential fashion;cancellation support for Futures and coroutines;synchronization primitives for use between coroutines in a single thread,
mimicking those in the threading module;an interface for passing work off to a threadpool, for times when you
absolutely, positively have to use a library that makes blocking I/O calls.Note: The implementation of asyncio was previously called “Tulip”.InstallationTo install asyncio, type:pip install asyncioasyncio requires Python 3.3 or later! The asyncio module is part of the Python
standard library since Python 3.4.asyncio is a free software distributed under the Apache license version 2.0.Websitesasyncio project at GitHub: source
code, bug trackerasyncio documentationMailing list:python-tulip Google GroupIRC: join the#asynciochannel on the Freenode networkDevelopmentThe actual code lives in the ‘asyncio’ subdirectory. Tests are in the ‘tests’
subdirectory.To run tests, run:toxOr use the Makefile:make testTo run coverage (coverage package is required):make coverageOn Windows, things are a little more complicated.  Assume ‘P’ is your
Python binary (for example C:Python33python.exe).You must first build the _overlapped.pyd extension and have it placed
in the asyncio directory, as follows:C> P setup.py build_ext –inplaceIf this complains about vcvars.bat, you probably don’t have the
required version of Visual Studio installed.  Compiling extensions for
Python 3.3 requires Microsoft Visual C++ 2010 (MSVC 10.0) of any
edition; you can download Visual Studio Express 2010 for free fromhttp://www.visualstudio.com/downloads(scroll down to Visual C++ 2010
Express).Once you have built the _overlapped.pyd extension successfully you can
run the tests as follows:C> P runtests.pyAnd coverage as follows:C> P runtests.py –coverage
Package: asyncio37
This package replaces default implementation ofasyncioin Python 3.6 with
implementation in Python 3.7. Acontextvarslibraryfrom MagicStackis also
included to make sure the package functions well.NotesAfter installation, this package will replace the builtin implementation ofasyncioin Python 3.6. To use the builtin implementation, you have to
uninstall this package or add an environment variableUSE_BUILTIN_ASYNCIO=1to avoid loading the replacements.AsPyThreadStatein Python 3.6 does not include an unique identifier,
we cannot cache it when callingget_running_loop. Hence the performance
of the library may be degraded comparing to the original module in Python 3.7.LicenseThe whole package is released under Apache License 2.0. Codes underasynciomodule is copied from Python 3.7 source which is released under PSF License
Agreement with minimal modifications. Codes incontextvars.pyis copied from
MagicStack codes released under Apache License 2.0.
Package: asyncio-anywhere
asyncio-anywherePython package that makes it easy to run fast asyncio codeAre you trying to run async code in Python and getting the errorasyncio.run() cannot be called from a running event loop?
This package makes it easy to run asyncio-based async code in tricky execution environments:IPython-based notebooks (JupyterLab, AWS Sagemaker, Databricks, etc)trioapplicationscurioapplicationsOther Features:Useuvloopfor faster i/o - but without permanently changing the asyncio event loop policyRun any code which usesasyncioI/O.Type hints to support type-aware IDEsNon-Features:asyncio-anywhere does notmonkey-patchthe asyncio module.  This avoids unexpected
side-effects and potential future bugs.Usagepipinstallasyncio-anywhereimportasynciofromasyncio_anywhereimportasyncio_runasyncdefmyfunc():awaitasyncio.sleep(0.01)return"OK"result=asyncio_run(myfunc())print(result)Useasyncio_run()anywhere where you would normally have runasyncio.run().  Note that it also accepts a booleandebugparameter as the second parameter.
Package: asyncio-atexit
asyncio atexitAdds atexit functionality to asyncio:importasyncio_atexitasyncdefclose_db():awaitdb_connection.close()asyncio_atexit.register(close_db)atexitis part of the standard library,
and gives you a way to register functions to call when the interpreter exits.asyncio doesn't have equivalent functionality to register functions
when theevent loopexits:This package adds functionality that can be considered equivalent toatexit.register,
but tied to the event loop lifecycle. It:accepts both coroutines and synchronous functionsshould be called from a running event loopcalls registered cleanup functions when the event loop closesonly works if the application running the event loop callsclose()
Package: asyncio-buffered-pipeline
asyncio-buffered-pipelineParallelise pipelines of Python async iterables/generators.Installationpipinstallasyncio-buffered-pipelineUsage / What problem does this solve?If you have a chain of async generators, even though each is async, only one runs at any given time. For example, the below runs in (just over) 30 seconds.importasyncioasyncdefgen_1():forvalueinrange(0,10):awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalueasyncdefgen_2(it):asyncforvalueinit:awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalue*2asyncdefgen_3(it):asyncforvalueinit:awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalue+3asyncdefmain():it_1=gen_1()it_2=gen_2(it_1)it_3=gen_3(it_2)asyncforvalinit_3:print(val)asyncio.run(main())Thebuffered_pipelinefunction allows you to make to a small change, passing each generator through its return value, to parallelise the generators to reduce this to (just over) 12 seconds.importasynciofromasyncio_buffered_pipelineimportbuffered_pipelineasyncdefgen_1():forvalueinrange(0,10):awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalueasyncdefgen_2(it):asyncforvalueinit:awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalue*2asyncdefgen_3(it):asyncforvalueinit:awaitasyncio.sleep(1)# Could be a slow HTTP requestyieldvalue+3asyncdefmain():buffer_iterable=buffered_pipeline()it_1=buffer_iterable(gen_1())it_2=buffer_iterable(gen_2(it_1))it_3=buffer_iterable(gen_3(it_2))asyncforvalinit_3:print(val)asyncio.run(main())Thebuffered_pipelineensures internal tasks are cancelled on any exception.Buffer sizeThe default buffer size is 1. This is suitable if each iteration takes approximately the same amount of time. If this is not the case, you may wish to change it using thebuffer_sizeparameter ofbuffer_iterable.it=buffer_iterable(gen(),buffer_size=2)FeaturesOnly one task is created for eachbuffer_iterable, in which the iterable is iterated over, with its values stored in an internal buffer.All the tasks of the pipeline are cancelled if any of the generators raise an exception.If a generator raises an exception, the exception is propagated to calling code.The buffer size of each step in the pipeline is configurable.The "chaining" is not abstracted away. You still have full control over the arguments passed to each step, and you don't need to buffer each iterable in the pipeline if you don't want to: just don't pass those throughbuffer_iterable.
Package: asyncio-cache
asyncio-cacheA python library for asyncio caches (like functools cache and lru_cache)InstallationInstall the last released version usingpip:python3-mpipinstall--user-Uasyncio-cacheOr install the latest version from sources:gitclonegit@github.com:matan1008/asyncio-cache.gitcdasyncio-cache
python3-mpipinstall--user-U-e.UsageThe usage is similar tofunctools.cacheandfunctools.lru_cacheusage:fromasyncio_cacheimportcache@cacheasyncdefcached_read(reader):returnawaitreader.read(100)
Package: asyncio-cancel-token
Task cancellation pattern forasyncioapplications.Read more in thedocumentation on
ReadTheDocs.View the
change
log.Quickstartpipinstallasyncio-cancel-tokenDeveloper SetupIf you would like to hack on asyncio-cancel-token, please check out theEthereum Development Tactical
Manualfor information on how we do:TestingPull RequestsCode StyleDocumentationDevelopment Environment SetupYou can set up your dev environment with:gitclonegit@github.com:ethereum/asyncio-cancel-token.gitcdasyncio-cancel-tokenvirtualenv-ppython3venv.venv/bin/activatepipinstall-e.[dev]Testing SetupDuring development, you might like to have tests run on every file save.Show flake8 errors on file change:# Test flake8when-changed-v-s-r-1cancel_token/tests/-c"clear; flake8 cancel_token tests && echo 'flake8 success' || echo 'error'"Run multi-process tests in one command, but without color:# in the project root:pytest--numprocesses=4--looponfail--maxfail=1# the same thing, succinctly:pytest-n4-f--maxfail=1Run in one thread, with color and desktop notifications:cdvenvptw--onfail"notify-send -t 5000 'Test failure ⚠⚠⚠⚠⚠' 'python 3 test on asyncio-cancel-token failed'"../tests../cancel_tokenRelease setupFor Debian-like systems:apt install pandocTo release a new version:makereleasebump=$$VERSION_PART_TO_BUMP$$How to bumpversionThe version format for this repo is{major}.{minor}.{patch}for
stable, and{major}.{minor}.{patch}-{stage}.{devnum}for unstable
(stagecan be alpha or beta).To issue the next version in line, specify which part to bump, likemake release bump=minorormake release bump=devnum.If you are in a beta version,make release bump=stagewill switch to
a stable.To issue an unstable version when the current version is stable, specify
the new version explicitly, likemake releasebump="--new-version4.0.0-alpha.1devnum"
Package: asyncio-chainable
asyncio-chainableMaking asyncio coroutines chainableBuilt on: Python3 and Docker (alpine) and Poetry (Package Manager)Maintained by: Chris Lee [sihrc.c.lee@gmail.com]Installationpip3installasyncio_chainableExample Usageimportpytestfromasyncio_chainableimportasync_chainable,async_chainable_class@pytest.mark.asyncioasyncdeftest_simple_chain():classNumber:def__init__(self,num:int=0):self.num=num@async_chainableasyncdefadd(self,num:int):self.num+=numreturnself@async_chainableasyncdefsubtract(self,num:int):self.num-=numreturnselfassert(awaitNumber().add(5).subtract(2)).num==3@pytest.mark.asyncioasyncdeftest_class_chain():@async_chainable_classclassNumber:def__init__(self,num:int=0):self.num=numasyncdefadd(self,num:int):self.num+=numreturnselfasyncdefsubtract(self,num:int):self.num-=numreturnselfassert(awaitNumber().add(5).subtract(2)).num==3Contributing: Getting StartedDockerAdditional Python3 dependencies can be added to requirements.txtTests are located in ./testsTo run the docker container with the basic requirements, dependencies, and the package installed:$touch.env
$docker-composeupPoetry$ poetry install
Package: asyncio-channel
Asynchronous channels for communication and synchronization betweenasynciocoroutines.fromasyncio_channelimportcreate_channel# Create a new channel.ch=create_channel()# Put an item on the channel; block until the item is accepted.awaitch.put(x)# Take an item from the channel; block until an item is available.x=awaitch.take()# Do something each time an item is put on the channel.asyncforxinch:do_something(x)do_something_else(x)# Iteration stops when the channel is closed and drained.Also contains several utilities for piping items between channels, mixing multiple input channels, routing messages by topic, and more.
Package: asyncio-context
asyncio-contextTool for store data within asyncio task (for example, in all coroutines across handling aiohttp request) and enrich logging record with this data.Small, nice-looking and with annotations.Installpip install asyncio-contextExampleIt can be used for logging trace id and other info about request:...'formatters':{'standard':{'format':'[trace_id:%(trace_id)s] [user_id:%(user_id)s]:%(message)s'},},'filters':{'context2record':{'()':'asyncio_context.logging.Context2Record','ctx_name':'ViewsCtx'},},...fromasyncio_contextimportContextclassViewsCtx(Context):user_id:str='UNKNOWN'trace_id:str='NO_TRACE'ctx=ViewsCtx()log=logging.getLogger()classMyView(web.View):asyncdefget(self):ctx.trace_id=self.request.headers.get('X-Trace-Id',str(uuid.uuid4()))# orViewsCtx().user_id=self.request.match_info.get('user_id')log.info('Test request')# GET http://localhost:8080/user/123# [trace_id:ea38e89d-fba1-40a3-899e-297c6cd76732] [user_id:123]:Test requestContext can be copied to another asyncio task:task=asyncio.get_running_loop().create_task(another_task())ViewsCtx.copy_to_task(task)
Package: asyncio-contextmanager
Decorator that turns async generator functions into async context
managers.InstallationSupported versions of python:``3.6+``(since async generators were
introduced in python 3.6)pipinstallasyncio-contextmanagerUsageUsage is straightforward and simple:fromaiocontextimportasync_contextmanager@async_contextmanagerasyncdeffoo():yield'Foo!'
Package: asyncio-contextmanager-pool
asyncio-contextmanager-poolA library providing a pool-like object for holdingAsyncContextManagerinstances.Why?Some objects, like MongoDB connections to a Replica Set, are expensive to create, time-wise. As a result, they are usually created once and then used across the entire application. This mitigates, or eliminates, the costs associated with creating and setting up such objects.However, there are situations where one may need to dynamically create such objects. One such example would be a multi-tenant API that can talk to multiple instances.One could usecachetoolsto hold the references, perhaps in aTTLCache, so that not "too many" instances are kept (especially when not used), but then they must also make sure that instances are cleaned up properly, sometimes with some leniency (TTL).FeaturesAsync Context Manager (async with) support to manage objectsMemoizes instances based on the arguments used to create them, which prevents duplicates and saves init timeProvides TTL support, so that objects are kept for a set period of time after not being used, which again helps preventing duplicationUsageimportasynciofromasyncio_contextmanager_poolimportPoolclassExample:"""A dummy implementation of an AsyncContextManagerthat "knows" when it was used."""def__init__(self,message:str)->None:self.message=messageself.enter_called=0self.exit_called=0asyncdef__aenter__(self):self.enter_called+=1returnselfasyncdef__aexit__(self,*args,**kwargs):self.exit_called+=1asyncwithPool(Example,ttl=5)asp:# Get an instance of Exampleasyncwithp.get("hello, world")asinst_1:# Use itassertinst_1.message=="hello, world"# Here, under normal circumstances, `inst_1` is still aliveassertinst_1.exit_called==0# So, if I `get` it again...asyncwithp.get("hello, world")asinst_2:# And use it...assertinst_2.message=="hello, world"# I will get the exact same objectassertinst_1isinst_2# Now, let's assume some time passes...awaitasyncio.sleep(10)# Here, inst_1 already expired, so inst_3# will be a new object...asyncwithp.get("hello, world")asinst_3:assertinst_3.message=="hello, world"assertinst_1isnotinst_3assertinst_1.exit_called==1# And after the `async with` block, everything is cleaned:assertinst_3.exit_called==1NotesPickle supportIf aPoolinstance is copied via Pickle (e.g., throughmultiprocessing.Processor aconcurrent.futures.ProcessPoolExecutor), the instances are not copied.This is by design, because:Some objects should not be copied between processes (e.g.,pymongo.MongoClient)Object expiration usesasyncio's Timer functions, which are attached to the Event Loop. Event Loops cannot be shared between processes.
Package: asyncio-datagram
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()