Saravanan666/pypi-org huggingface dataset:
Package: asyncio-multilock
asyncio-multilockasyncio_multilockprovidesMultiLock, anasynciobased lock with built-in
shared/exclusive mode semantics.MultiLock.lockedcan be in one of three states:None- not locked;MultiLockType.SHARED- acquired one or more times in shared mode;MultiLockType.EXCLUSIVE- acquired one time in exclusive mode.When a lock is acquired, aHashablehandle is returned which uniquely identifies
the acquisition. This handle is used to release the acquisition.fromasyncioimportcreate_task,sleepfromasyncio_multilockimportMultiLock,MultiLockTypelock=MultiLock()assertnotlock.lockedshared1=awaitlock.acquire(MultiLockType.SHARED)assertlock.lockedisMultiLockType.SHAREDshared2=awaitlock.acquire(MultiLockType.SHARED)asyncdefwait_release_shared(delay:float)->None:awaitsleep(delay)lock.release(shared1)lock.release(shared2)create_task(wait_release_shared(3))# Acquisition context manager.asyncwithlock.context(MultiLockType.EXCLUSIVE)asexclusive:# Blocked for 3 seconds.assertlock.lockedisMultiLockType.EXCLUSIVEThe lock can also be acquired synchronously, returning no handle if the acquisition
fails.fromasyncio_multilockimportMultiLock,MultiLockTypelock=MultiLock()assertnotlock.lockedshared=lock.acquire_nowait(MultiLockType.SHARED)assertsharedexclusive=lock.acquire_nowait(MultiLockType.EXCLUSIVE)assertnotexclusiveassertlock.lockedisMultiLockType.SHAREDThe lock can also be monitored for when a given lock type is next acquirable.fromasyncio_multilockimportMultiLock,MultiLockTypelock=MultiLock()asyncwithlock.notify(MultiLockType.SHARED)asevent:awaitevent.wait()print("shared lock is acquirable")event.clear()
Package: asyncio-orvibo
asyncio-orviboControl Orvibo devices with Python 3 using asyncio (single threaded with event loop). Currently supports the S20 WiFi Smart Switch and AllOne IR.Usagefromasyncio_orviboimports20importasyncioimporttracebackasyncdeftest_switch_all_off_on():dict_devices=awaits20.S20.discovery()for_,sindict_devices.items():ifawaits.state_change(0):print("State off OK%s",s)else:print("State off FAIL%s",s)awaitasyncio.sleep(5)for_,sindict_devices.items():ifawaits.state_change(1):print("State on OK%s",s)else:print("State on FAIL%s",s)loop=asyncio.get_event_loop()try:loop.run_until_complete(test_switch_all_off_on())except:traceback.print_exc()################################################fromasyncio_orviboimportalloneimportasyncioimporttracebackimportbinasciiasyncdeftest_emit(k):dict_devices=awaitallone.AllOne.discovery()payload=binascii.unhexlify(k)for_,aindict_devices.items():rv=awaita.emit_ir(payload)ifrv:print("Emit OK%s%s",a,binascii.hexlify(rv).decode('utf-8'))else:print("Emit failed")loop=asyncio.get_event_loop()try:loop.run_until_complete(test_emit('00000000a801000000000000000098018e11951127029b0625029906270299062702380227023a0225023802270238022d023202270299062702990627029806270238022702380227023802270238022802370227023802270238022702980627023802240245021c02380227023802270238022702980627029c0623023802270298062702990627029b062502990627029906270220b7a1119d11270299062702990628029b06250238022702380227023802270238022702380227029906270299062702990627023802270238022a0234022702380227023802260238022702380226029a06260238022602380226023802260241021e02380227029b0624029906270238022702980627029b0625029906270299062702990629021db79f11a2112502990627029b0625029906270238022702380227023802270238022a02350227029906270299062702990628023702260238022702380227023802270238022702380226023b02240299062702380226023802270238022602380227023c0223029906270299062702380226029b062402990627029906270299062802980627020000'))except:traceback.print_exc()ContributionsPull requests are welcome. Possible areas for improvement:Additional Orvibo devices (CT10 for example, I have reverse engineered this device I only need time to write the code).Expand S20 functions: Timers, configuration, etcDisclaimerNot affiliated with Shenzhen Orvibo Electronics Co., Ltd.
Package: asyncio-oss
An asynchronous python client SDK for OSS(Aliyun Object Storage Service).It has been verified and used in the production environment with QPS ≈ 500  for about half a year, so you can use it with confidence.InstallationPyPI (recommend)$pipinstallasyncio-ossLocal compilation$gitclonegit@github.com:Yaocool/async-oss.git
$pythonsetup.pybdist_wheel
$pipinstall./dist/asyncio_oss-*-py3-none-any.whlExamplesFor more examples, please refer to thetestdirectory.importloggingimportasyncio_ossimportasyncioimportoss2OSS_ENDPOINT='https://oss-cn-hangzhou.aliyuncs.com'# definition in https://help.aliyun.com/document_detail/31837.htmlOSS_KEY='<Your AccessKeyID>'OSS_SECRET='<Your AccessKeySecret>'OSS_AUTH=oss2.Auth(OSS_KEY,OSS_SECRET)BUCKET_NAME='<your bucket name>'OBJECT_KEY='<your object key>'asyncdefmain():asyncwithasyncio_oss.Bucket(OSS_AUTH,OSS_ENDPOINT,BUCKET_NAME)asbucket:# Put Objectawaitbucket.put_object(OBJECT_KEY,b'your bytes data')# Get Objectresult=awaitbucket.get_object(OBJECT_KEY)awaitresult.read()# Head Objecthead_res=awaitbucket.head_object(OBJECT_KEY)print(head_res.content_length)# List Objectsforobjin(awaitbucket.list_objects()).object_list:print(obj.key)# Delete Objectawaitbucket.delete_object(OBJECT_KEY)if__name__=='__main__':# open global loglog_file_path="example_logfile.log"asyncio_oss.set_file_logger(log_file_path,'asyncio_oss',logging.DEBUG)loop=asyncio.get_event_loop()loop.run_until_complete(main())Discussions Or IssuesAny questions can be raised inDiscussionsorIssues, I will answer them from time to time.
Package: asyncio-pause
Based onhttps://github.com/jgillick/python-pauseSuspend the execution of your program for a given amount of time using asyncio. This works similarly totime.sleep, but uses your computers timestamp to track time, versus a counter.For example, traditionally usingtime.sleep(3600), will pause the program for 60 minutes. If your computer goes into standby mode during minute one, and wakes up several hours later, your program will continue to be paused for 59 minutes.On the other hand, withpause.seconds(3600), if your computer goes into standby mode for several hours, the program will continue immediately after the machine wakes back up since the minimum amount of time has passed since the pause was started.How it worksWhen you create a pause, it will determine what the end time of that pause should be. Then a loop will be started that will continually check the current time against the end time. When the current time is equal or greater than the end time, the method will allow your program can resume.PrecisionThe precisionshouldbe within 0.001 of a second, however, this will depend on how precise your system sleep is and other performance factors.This module computes the pause duration between now and the future date, and then sleeps for half of this duration. After this time, it recomputes the new pause duration, repeating this process until the desired time is reached.InstallDownload the source code and run the following command:sudo python ./setup.py installOr, without downloading, install withpip:sudo pip install asyncio-pauseExamples:Pause for half a second:import asyncio-pause
await pause.milliseconds(500)Or:import asyncio-pause
await pause.seconds(0.5)Pause for 1 minute:import asyncio-pause
await pause.minutes(1)Pause for 2 days:import asyncio-pause
await pause.days(2)Pause until a unix time, with millisecond precision:import asyncio-pause
await pause.until(1370640569.7747359)Pause using datetime:import asyncio-pause, datetime
dt = datetime.datetime(2013, 6, 2, 14, 36, 34, 383752)
await pause.until(dt)Functionsdays(num)Pause for this many dayshours(num)Pause for this many hoursmilliseconds(num)Pause for this many millisecondsminutes(num)Pause for this many minutesseconds(num)Pause for this many secondstime(num)Same as PauseFor.seconds()until(time)Pause your program until a specific end time.
‘time’ is either a unix timestamp in seconds (i.e. seconds since Unix epoch) or datetime objectweeks(num)Pause for this many weeks
Package: asyncio-periodic
# periodicSimple tool for run asyncio tasks periodically.# Setup```bashpip install asyncio-periodic```# Example usage```pythonimport asynciofrom datetime import datetimefrom periodic import Periodicasync def periodically(param):print(datetime.now(), 'Yay!', param)await asyncio.sleep(1)print(datetime.now(), 'Done!')async def main():p = Periodic(3, periodically, 'Periodically!')await p.start()if __name__ == "__main__":loop = asyncio.get_event_loop()loop.create_task(main())loop.run_forever()```
Package: asyncio_pinger
PingerPinger based on asyncio library.Pinger collect servers pings and show it in reversed order (first with worst
ping, last with best ping).Instalationpipinstallasyncio_pingerUsageCreate file like this:Argentina, Buenos Aires (PPTP/L2TP): bn-ar.boxpnservers.com
Argentina, Buenos Aires (SSTP): sstp-bn-ar.boxpnservers.comRun Pythonfromasyncio_pingerimportPingerp=Pinger(path_to_file)p.run()p.print_results()
Package: asyncio-pipe
Asyncio PipeThis package allows you to read from amultiprocessing.Connectionobject
without blocking anasyncioevent loop.TheConnectionclass has the same API functions asmultiprocessing.Connection.Usageimportasyncioimportmultiprocessingimportasyncio_pipeasyncdefreader(read):connection=asyncio_pipe.Connection(read)print(awaitconnection.recv())defwriter(write):write.send('Hello World')read,write=multiprocessing.Pipe(duplex=False)writer_process=multiprocessing.Process(target=writer,args=(write,))writer_process.start()asyncio.get_event_loop().run_until_complete(reader(read))
Package: asyncio-pool
asyncio-poolPool of asyncio coroutines with familiar interface. Supports python 3.5+ (including PyPy 6+, which is also 3.5 atm)AioPool makes sureno moreandno less(if possible) thansizespawned coroutines are active at the same time.spawnedmeans created and scheduled with one of the pool interface methods,activemeans coroutine function started executing it's code, as opposed towaiting-- which waits for pool space without entering coroutine function.Read more atgithub page.
Package: asyncio-pool-ng
asyncio-pool-ngAboutAsyncioPoolNGtakes the ideas used inasyncio-pooland wraps them around anasyncio.TaskGroup.AsyncioPoolhas three main functionsspawn,map, anditermap.spawn: Schedule an async function on the pool and get a future back which will eventually have either the result or the exception from the function.map: Spawn an async function for each item in an iterable object, and return a set containing a future for each item.asyncio.wait()can be used to wait for the set of futures to complete.When theAsyncioPoolcloses, it will wait for all tasks to complete. All pending futures will be complete once it is closed.itermap: Works similarly tomapbut returns anAsync Generatorwhich yields each future as it completes.Differences from asyncio-poolasyncio-pool-ngimplementsPython typingand passes validation checks withmypy's strict mode. This helps IDEs and static type checkers know what type of result to expect when getting data from a completed future.asyncio-pooluses callbacks to process data before returning it;asyncio-pool-ngonly returnsFutureinstances directly. The future will contain either a result or an exception which can then be handled as needed.Whileasyncio-poolschedulesCoroutineinstances directly,asyncio-pool-ngtakes the callable and arguments, and creates the Coroutine instance at execution time.Exampleimportasyncioimportloggingfromrandomimportrandomfromasyncio_poolimportAsyncioPoollogging.basicConfig(level=logging.INFO)asyncdefworker(number:int)->int:awaitasyncio.sleep(random()/2)returnnumber*2asyncdefmain()->None:result:int=0results:list[int]=[]asyncwithAsyncioPool(2)aspool:"""spawn task and wait for the results"""result=awaitpool.spawn(worker,5)assertresult==10logging.info(f"results for pool.spawn(worker, 5):{result}")"""spawn task and get results later"""future:asyncio.Future[int]=pool.spawn(worker,5)# do other stuffresult=awaitfutureassertresult==10"""map an async function to a set of values"""futures:set[asyncio.Future[int]]=pool.map(worker,range(10))awaitasyncio.wait(futures)results=[x.result()forxinfutures]logging.info(f"results for pool.map(worker, range(10)):{results}")results.sort()assertresults==[0,2,4,6,8,10,12,14,16,18]"""iterate futures as they complete"""logging.info("results for pool.itermap(worker, range(10)):")results=[]asyncforfutureinpool.itermap(worker,range(10)):results.append(future.result())logging.info(f">{future.result()}")results.sort()assertresults==[0,2,4,6,8,10,12,14,16,18]asyncio.run(main())
Package: asyncio-portier
asyncio-portieris a set of helpers forthe Portier Identity Provider. It is based onthe portier-python packagebut modified to work withasyncio.UsageThe helpers work in much the same way as the ones inportier-python. Checkthe demos directoryfor usage
examples.Notesportier-pythondoesn’t seem to work quite right with Redis as the cache
backend, so there are a few Redis-specific modifications. This may change in
the future.I expected the calls to cryptographic libraries to be blocking, but I saw no
improvement from running those calls in anExecutoras perhttps://docs.python.org/3/library/asyncio-eventloop.html#executor.
Package: asyncio-pypes
(pronounced "pipes")Scalable async pipelines in Python, made easy.📝 Table of ContentsAboutGetting StartedUsageBuilt UsingTODOContributingAuthorsAcknowledgments🧐 AboutThis package is designed to make building asynchronous streams that balance and
scale automaticallyeasy. Built on pure Python -- no dependencies -- this
framework can be used for variable, decoupled, task-based workloads like
web scraping, database management operations, and more. Scale this out-of-the-box,
with minimal hardware and coding, to process 10k+/s on production loads.Simple pipelinesimport pypes

app = pypes.App()

@app.task(interval=1.0)
async def every_second():
    return datetime.utcnow()

@app.task()
async def task1(stream):
    async for s in stream:
        print(f"streaming from task1: {s}")
        yield obj

if __name__ == '__main__':

    pipeline = every_second \
               .map(task1)

    pipeline.run()To scaled pipelinesimport pypes
import aiohttp

app = pypes.App()

@app.task(interval=0.1)
async def every_second():
    return "http://www.google.com"

@app.task(scaler=pypes.scale.TanhTaskScaler()) #  this scales workers automatically to consume incoming requests
async def task1(stream):
    async for s in stream:
        yield await aiohttp.get(s)

async def task2(stream):
    async for s in stream:
        if s.response_code != 200:
            print("failed request: {s}")
        yield

if __name__ == '__main__':

    pipeline = every_second \
               .map(task1)
               .reduce(task2)

    pipeline.run()🏁 Getting StartedStart with a simple pipeline, and build out from there!import pypes

app = pypes.App()

@app.task(interval=1.0)
async def every_second():
    return datetime.utcnow()

@app.task()
async def task1(stream):
    async for s in stream:
        print(f"streaming from task1: {s}")
        yield obj

if __name__ == '__main__':

    pipeline = every_second \
               .map(task1)

    pipeline.run()For more, seereadthedocsPrerequisitespypesis based on pure Python (3.5+) and does not require other dependencies.Installingpip install pypes🔧 Running the testsTo be created!Break down into end to end testsTo be created!And coding style testsTo be created!🎈 UsageImport the libraryimport pypesCreate an App objectapp = pypes.App()Create a trigger task@app.task(interval=1.0)
async def every_second():
    return 1Create downtream tasks@app.task()
async def task_n(stream):
    async for s in stream:
        # process "s" here
        yieldCreate + configure the pipelinepipeline = every_second \
            .map(task_n)Run the pipelinepipeline.run()This will run continuously until interrupted.⛏️ Built UsingPythonasyncio✔️ TODOExtend to multithreadsExtend to multiprocessBuild visualization serverAdd pipeline pipe functions (join, head, ...)✍️ Authors@mroumanosContributors: you?🎉 Acknowledgementsfaust streaming
Package: asyncio-railgun
Python asyncio railgunA python3.4+ asyncio library wrapper for utilzing asyncio tasks and gather(*) functionality. Library is meant to make concurrent tasks easier and safer through the use of semaphores.Table of contentsRequirementsThis library requires Python 3.6 and above.Note:You may need to usepython3before your commands to ensure you use the correct Python path. e.g.python3 --versionpython--version

--or--

python3--versionInstallationWe recommend usingPyPIto install the Slack Developer Kit for Python.pip3installasyncio-railgun==0.0.1Basic Usage examplesRunfromasyncioimportget_event_loopfromrailgun.railgunimportRailgunfromhttpimportclientdefexample_call_api(host='www.google.com',url='/'):conn=client.HTTPSConnection(host,port=443,timeout=5)conn.request(method='GET',url=url)response=conn.getresponse()returnresponse.statusrail_gun=Railgun(semaphores_count=10)results=rail_gun.run([example_call_api(),example_call_api()])print(results)Run asyncTBDRepeatTBDSupportTBDContact me onchristogoosen@gmail.comOtherwise see the examples and log an issue.
Package: asyncio-red
asyncio-RED (Redis Event Driven)Powers your microservices with event driven approach using redis as a backend.Support both publishing and subscribing using lists, channels and streams.pydanticis being used for events validation.s3can be used for sharing event schemas between services.Installationpip install asyncio-redSimple producerfromredis.asyncioimportRedisfromasyncio_redimportRED,Via,BaseEventfrompydanticimportFieldclassEventV1List(BaseEvent):key:str=Field(...,title='Key description')classEventV1Channel(BaseEvent):key:str=Field(...,title='Key description')classEventV1Stream(BaseEvent):key:str=Field(...,title='Key description')redis_client=Redis()red=RED(app_name=str('service_1'),redis_client=redis_client)red.add_out(event=EventV1List,via=Via.LIST,target_name='events_list')red.add_out(event=EventV1Channel,via=Via.CHANNELS,target_name='events_channel')red.add_out(event=EventV1Stream,via=Via.STREAMS,target_name='events_stream')asyncdefyour_awesome_function():# dispatch eventsawaitEventV1List(key='value').dispatch()# this one will be put to a listawaitEventV1Channel(key='value').dispatch()# this one will be pushed to a channelawaitEventV1Stream(key='value').dispatch()# this one will be pushed to a streamSimple consumerfromredis.asyncioimportRedisfromasyncio_redimportRED,Via,BaseEventfrompydanticimportFieldclassEventV1List(BaseEvent):key:str=Field(...,title='Key description')classEventV1Channel(BaseEvent):key:str=Field(...,title='Key description')classEventV1Stream(BaseEvent):key:str=Field(...,title='Key description')redis_client=Redis()red=RED(app_name=str('service_2'),redis_client=redis_client)asyncdefevent_handler(event):print(event)red.add_in(event=EventV1List,via=Via.LIST,handlers=(event_handler,),list_name="events_list",)red.add_in(event=EventV1Channel,via=Via.CHANNELS,handlers=(event_handler,),error_handler=event_handler,channel_name="events_channel")red.add_in(event=EventV1Stream,via=Via.STREAMS,handlers=(event_handler,event_handler),stream_name="events_stream",group_name="events_group",consumer_name="consumer_name")awaitred.run()Shared events registryThere is a possibility to keep event schemas registry on the S3 and share the schema across
different services. You'll need an AWS account and keys with access to S3.Go to app root dir and initialize asyncio-red:asyncio_redinit--app-name=<appname>--s3-bucket=<bucketname>This will create an initial structure.
Define your events atred/registry/<app name>.py:frompydanticimportFieldfromasyncio_red.eventsimportBaseEventclassEventV1List(BaseEvent):key:str=Field(...,title='Key description')classEventV1Channel(BaseEvent):key:str=Field(...,title='Key description')classEventV1Stream(BaseEvent):key:str=Field(...,title='Key description')push application events schemas to a registry:asyncio-red pushon a different service you can pull shared schemas - do the same steps, e.g. init structure and runasyncio-red pull
Package: asyncio-redis-ha
High Availability package and Sentinel client for thePEP 3156Python event loop.This package is a wrapper/plugin forasyncio-redisasynchronous, non-blocking client for a
Redis server. It depends on asyncio (PEP 3156) and therefor it requires Python
3.3 or 3.4. If you’re new to asyncio, it can be helpful to check outthe asyncio documentationfirst.FeaturesSentinel support ontop of asyncio-redis:rolesentinelsslavesget_master_addr_by_nameExtended Redis support (versions 3.x)roleMostly testedall tests fromasyncio-redisare greennew functionality covered and guaranteed to run in same conditionsfailover scenarios tested manuallyDependenciesRedis cluster with Sentinel solution requiresRedis 3.xThis package uses and heavily depends onasyncio-redis,
because of the dependencies on package internals
(due to required changes to support sentinel operations)
currently requirement fixed at version0.14.3I will manually update this dependency after ensuring that internals are compatible.Roadmapimplement pool reinitialization on master connection lossadd repeat/backoff wrapper as part of the package (coroutine or decorator)provide automated testing for failover scenariosimplement preemptive connection reconfiguration
(instant failover detection based on channel events from Sentinel daemon)hiredis supportUser GuideUsage is the very same as forasyncio-redispackage Pool object,
except for initialization of an entry pointInitialize a ConnectionManagerc=yield fromConnectionManager.create(cluster_name='mymaster',sentinels=[('172.17.0.4',26379),('172.17.0.6',26379),('172.17.0.7',26379)],poolsize=5)#  start using just like asyncio-redisyield fromc.set('key','value')
Package: asyncio-redis-rate-limit
asyncio-redis-rate-limitRate limiter for async functions using Redis as a backend.FeaturesSmall and simpleCan be used as a decorator or as a context managerCan be used for both clients and serversWorks withasyncioWorks with any amount of processesWorks with bothredis.asyncio.client.RedisandaioredisFree of race-conditions (hopefully!)Supportsredissince7.0Fully typed with annotations and checked with mypy,PEP561 compatibleInstallationpipinstallasyncio-redis-rate-limitExtras available:pip install asyncio-redis-rate-limit[redis]pip install asyncio-redis-rate-limit[aioredis](for python versions<3.11)ExampleAs a decorator:>>>fromasyncio_redis_rate_limitimportrate_limit,RateSpec>>>fromredis.asyncioimportRedisasAsyncRedis# pip install redis>>>redis=AsyncRedis.from_url('redis://localhost:6379')>>>@rate_limit(...rate_spec=RateSpec(requests=1200,seconds=60),...backend=redis,...)...asyncdefrequest()->...:......# Do something useful! Call this function as usual.Or as a context manager:>>>fromasyncio_redis_rate_limitimportRateLimiter,RateSpec>>>fromredis.asyncioimportRedisasAsyncRedis# pip install redis>>>redis=AsyncRedis.from_url('redis://localhost:6379')>>>asyncdefrequest()->...:...asyncwithRateLimiter(...unique_key='api-name.com',...backend=redis,...rate_spec=RateSpec(requests=5,seconds=1),...):......# Do the request itself.LicenseMITCreditsThis project was generated withwemake-python-package. Current template version is:1d63652fbb33ebe2f6d932f511b7f529a4ce2d2a. See what isupdatedsince then.