Saravanan666/pypi-org huggingface dataset:
Package: asyncpusher
asyncpusher is an asynchronous python client library forPusherFeaturesUses well-maintainedaiohttp's websocket libraryReliable connectionAuto handles reconnectionAsynchronousFastSupports Pusher Channelsprotocol 7Support presence and private channelsInstall$ python3 -m pip install asyncpusherUsageimportasyncioimportloggingimportsysfromasyncpusher.channelimportChannelfromasyncpusher.pusherimportPusherlogging.basicConfig(stream=sys.stdout,level=logging.DEBUG)asyncdefhandle_event(data):logging.info(f"{market}{data}")asyncdefmain():loop=asyncio.get_running_loop()pusher=Pusher("<PUSHER_APP_KEY>",loop=loop)pusher.channels[channel_name]=channelawaitpusher.connect()channel_name="<CHANNEL_NAME>"channel=awaitpusher.subscribe(channel_name)channel.bind("diff",handle_event)awaitasyncio.sleep(5)awaitpusher.unsubscribe(channel_name)awaitasyncio.sleep(1)awaitpusher.disconnect()asyncio.run(main())
Package: async-pushover-client
async_pushover_clientПроект представляет собой набор синхронных и асинхронных методов для работы сAPI PushOverУстановкаpipinstallasync_pushover_clientИспользованиеСоздайте.envфайл, и поместите туда переменныеPUSHOVER_DEVICE_ID=ВАШ ИД устройства, если его нет зарегистрируется автоматически
PUSHOVER_EMAIL_USERNAME=email аккаунта
PUSHOVER_PASSWORD=пароль аккаунтаИли создайте файлauth_data.jsonи положите его в корень проекта.{"email":"example@example.com","password":"password","secret":"secret","device_id":"device_id"}После первого успешного запуска worker файл создастся автоматически, вы так же можете вызвать методfromasync_pushover_client.mainimportOpenAPIfromasync_pushover_client.settingsimportDEVICE_ID,PASSWORD,EMAIL_USERNAMEapi=OpenAPI(email=EMAIL_USERNAME,password=PASSWORD,device_id=DEVICE_ID)api.launch_preparation()# ИЛИ его асинхронное представление a_launch_preparation()Для того, что бы запустить асинхронный worker достаточно переопределить методreceiver_messages, или методon_message, если вы хотите работать с сырыми данными.fromasync_pushover_client.workerimportWSClientPushOverfromasync_websocket_client.appsimportAsyncWebSocketAppclassMyTestCase(WSClientPushOver):asyncdefreceiver_messages(self,message:dict):print(self.messages)print(message)client=AsyncWebSocketApp('wss://client.pushover.net/push',MyTestCase())client.asyncio_run()Метод получаетmessage, у которого есть все данные представляемые API PushOver.
Далее примените фантазию, и решите что вы сделаете cmessage, который будет хранить в себе одно сообщение,
илиself.messages, хранящий в себе не полученные сообщения на момент, пока worker не работал.Вы так же можете поработать с методами получения и удаления сообщений, без использования WebSocket.
Для этого достаточно импортировать классOpenAPIfromasync_pushover_client.mainimportOpenAPIfromasync_pushover_client.settingsimportDEVICE_ID,PASSWORD,EMAIL_USERNAMEapi=OpenAPI(email=EMAIL_USERNAME,password=PASSWORD,device_id=DEVICE_ID)messages=api.receiving_notifications()print(messages)
Package: asyncpy
安装: pip install asyncpy## AsynpyAsynpy 是一个异步请求框架，基于asyncio和aiohttp，实现便捷高效的从网络上抓取数据“With reference to the design pattern of scrapy, an asynchronous co-processing method is adopted to simplify some operations and complete the tasks of web crawler more easily and efficiently”### asyncio
asyncio是Python 3.4版本引入用来编写并发代码的标准库，直接内置了对异步IO的支持。
asyncio的编程模型就是一个单线程的消息循环。
从asyncio模块中直接获取一个EventLoop的引用，然后把需要执行的协程扔到EventLoop中执行，就实现了异步IO。### aiohttp
aiohttp - 基于asyncio实现的HTTP框架。
aiohttp强调的是异步并发。提供了对asyncio/await的支持，可以实现单线程并发IO操作。#### 单线程的asyncio为什么速度会更快呢？
- 多线程是基于系统的，协程是基于线程的，多线程上下文切换有陷入内核态的消耗，协程就没有，协程更轻量
- Python的GIL阻止两个线程在同一个程序中同时执行，有时候多线程并没有单线程速度快。
- 而Scrapy是基于twited的单线程框架，消息队列和事件循环在一个线程来回切换，downloader是多线程的#### 详细操作文档请参考博客或者github:https://blog.csdn.net/weixin_43582101/article/details/106258518https://github.com/lixi5338619/asyncpyThanks : Scrapy、Ruia、Looter、asyncio、aiohttp公众号《Pythonlx》
Package: async-pycatbox
async_pycatboxA simple Python library for uploading files to catbox.moe, and based off of cazqew's pycatbox, with the only significant change being that it's now supports asynchronous uploading.API documentationhttps://catbox.moe/tools.phpInstall the current version withPyPI:pipinstallasync_pycatboxOr from Github:https://github.com/challos/async_pycatboxExamplefromasync_pycatboximportUploaderimportasynciouploader=Uploader()asyncdefmain():upload=awaituploader.upload('py',open('test.py','rb').read())print(upload)asyncio.run(main())# https://files.catbox.moe/bav6l3.pyContributingBug reports and/or pull requests are welcome. I also copied most of this with minor changes/additions from cazqew's pycatbox (I was unable to make a pull/fork request due to being unable to find his Github page).LicenseThe module is available as open source under the terms of theApache License, Version 2.0
Package: async-pymongo
async_pymongoAsynchronous wrapper for pymongoComparisonInstallingpip3installasync_pymongoUsagefromasync_pymongoimportAsyncClientasyncdefmain():conn=AsyncClient("mongodb://...")db=conn["database_name"]col=db["collections_name"]awaitcol.insert_one({"name":"John Smith","age":25})asyncfordataincol.find({}):print(data["name"])The rest function are same with pymongo but with await
Package: asyncpyspapi
asyncpyspapiAPIwrapper for SP servers written in Python.InstallationRequires Python 3.8 or higherWindowspipinstallasyncpyspapiLinux/macOSpip3installasyncpyspapiQuick exampleChecking the balanceimportasyncpyspapiclient=asyncpyspapi.SPAPI(card_id='card_id',token='token')balance=awaitclient.get_balance()print("Balance:",balance)Linkspyspapi discord serverpyspapi documentationPyPiAPI documentation for SP sites
Package: asyncpysupla
AsyncPySuplaA simplistic (and incomplete!) async wrapper forSupla's OpenAPI, used mainly forHomeAssistantintegration.This isPySupla'ssister library.I'm in no way affiliated with Supla and Zamel: I love their devices, but prefer to use all my Smart Home devices from one app.See tests directory for usage examples.Currently, there are only integration tests: to run them, you have to export the following environmental variables:SUPLA_SERVER - an address of Supla's cloud server you want to test against (ex. srv1.supla.org, or (better) your own test instance).SUPLA_PERSONAL_ACCESS_TOKEN - a personal access token you can gethere(if you use Supla's server of course). PySupla currently does not support OAuth2.SUPLA_SHUTTER_ID - an ID of a shutter type device to test against (this is what I'm mainly using Supla for).Contributors welcome!
Package: async-python-schema-registry-client
Async Python Rest Client Schema RegistryAsync Python Rest Client to interact againstschema-registryconfluent server to manageAvro Schemasresources.Requirementspython 3.6+, fastavro, requests-async, aiofilesInstallationpipinstallasync-python-schema-registry-clientClient API, Serializer and Schema Server descriptionDocumentation:https://marcosschroh.github.io/async-python-schema-registry-client.ioWhen to use this libraryUsually, we have a situacion in which we have producers/consumers that serialize/deserialize events to send/receive from Kafka topics. In this picture, we can imagine aFaustorFlinkapplication receiving/sending messages (encoded with an Avro schema)Avro schemashave to be maintained and also need to be used to encode/decode events. On those situation this library is convenient to use.Summary:When we want to build an application to administrateAvro Schemas(register, update compatibilities, delete old schemas, etc.)When we have a process that needs to serialize/deserialize events to send/receive to/from a kafka topicsDevelopmentThe tests are run against theSchema Serverusingdocker compose, so you will needDockerandDocker Composeinstalled../scripts/testLint code:./scripts/lint
Package: async-python-youtube
Python: YouTubeAsynchronous Python client for the YouTube V3 API.AboutThis package allows you to interact with the YouTube V3 API.Installationpipinstallasync-python-youtubeChangelog & ReleasesThis repository keeps a change log usingGitHub's releasesfunctionality. The format of the log is based onKeep a Changelog.Releases are based onSemantic Versioning, and use the format
ofMAJOR.MINOR.PATCH. In a nutshell, the version will be incremented
based on the following:MAJOR: Incompatible or major changes.MINOR: Backwards-compatible new features and enhancements.PATCH: Backwards-compatible bugfixes and package updates.ContributingThis is an active open-source project. We are always open to people who want to
use the code or contribute to it.We've set up a separate document for ourcontribution guidelines.Thank you for being involved! :heart_eyes:Setting up development environmentThis Python project is fully managed using thePoetrydependency manager. But also relies on the use of NodeJS for certain checks during development.You need at least:Python 3.10+PoetryNodeJS 12+ (including NPM)To install all packages, including all development requirements:npminstall
poetryinstallAs this repository uses thepre-commitframework, all changes
are linted and tested with each commit. You can run all checks and tests
manually, using the following command:poetryrunpre-commitrun--all-filesTo run just the Python tests:poetryrunpytestAuthors & contributorsThe original setup of this repository is byJoost LekkerkerkerFor a full list of all authors and contributors,
checkthe contributor's page.LicenseMIT LicenseCopyright (c) 2023 Joost LekkerkerkerPermission 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: async-qiwi
Installation | УстановкаWindowspip install async-qiwiLinuxpip3 install async-qiwiInformation | ИнформацияАктуальная версия AsyncQiwi 0.1.0Methods | ФyнкцииПолучение актуального баланса по нужной валюте
Получение номера телефона
Работа с Qiwi P2P Kassa
Package: asyncqt
asyncqt - asyncio + PyQt5/PySide2asyncqtis an implementation of thePEP 3156event-loop with Qt. This
package is a fork ofquamashfocusing on modern Python versions, with
some extra utilities, examples and simplified CI.Requirementsasyncqtrequires Python >= 3.5 and PyQt5 or PySide2. The Qt API can be
explicitly set by using theQT_APIenvironment variable.Installationpip install asyncqtExamplesYou can find usage examples in theexamplesfolder.
Package: asyncqtpy
asyncqtpy - asyncio + qtpyIMPORTANT: This project is unmaintained. Use other alternatives such as https://github.com/CabbageDevelopment/qasyncasyncqtpyis an implementation of thePEP 3156event-loop with Qt. This
package is a fork ofasyncqtupdated to use qtpy and 3.9+ type hints.Requirementsasyncqtpyrequires Python >= 3.9 and qtpy. The Qt API can be
explicitly set by using theQT_APIenvironment variable.Installationpip install asyncqtpyExamplesYou can find usage examples in theexamplesfolder.
Package: asyncrandom
AsyncrandomUtility for fetching one or more random numbers from the ANU Quantum Random Numbers Server by calling the endpoint athttps://qrng.anu.edu.au/API/jsonI.php.
Requests are executed asynchronously using the tornado networking framework.More information about how the numbers are generated can be found onhttps://qrng.anu.edu.au/.Requires tornado and its IOLoop to run.InstallationDownload the source and run the setup file:python setup.py installUsageA simple example of generating a single randomuint8:def handle_random_int(f):
    print(f.result())

f = asyncrandom.fetch()
f.add_done_callback(handle_random_int)

tornado.ioloop.IOLoop.current()Multiple numbers can be generated as well. In this example we generate 10:def handle_random_int(f):
    print(f.result())

f = asyncrandom.fetch(10)
f.add_done_callback(handle_random_int)

tornado.ioloop.IOLoop.current().start()By default, 8-bit unsigned integers are generated. Optionally, this can be changed to 16-bit. Example of generating 10 16-bit integers:def handle_random_int(f):
    print(f.result())

f = asyncrandom.fetch(10, asyncrandom.IntegerType.UINT16)
f.add_done_callback(handle_random_int)

tornado.ioloop.IOLoop.current()If called from the command, issues a synchronous call to the service. Optionally,--lengthand--typecan be specified as arguments, with default values of1and"uint-8"respectively.Command line example:$ asyncrandom --int-type=uint8 --length=1
105
Package: asyncrcon
asyncrconasyncrcon is a client side implementation of the Minecraft RCON protocol
using asyncio sockets for non-blocing socket handling.pip install asyncrconLinksDocsSource CodeExamplesLicenseUsage ExampleFor more examples, seehere.
Here, we are opening a RCON connection to add a given user to the servers whitelist. Then, we close the connection.fromasyncrconimportAsyncRCON,AuthenticationExceptionasyncdefadd_to_whitelist(user:str):rcon=AsyncRCON('loclahost:25575','secretRCONPassword')try:awaitrcon.open_connection()exceptAuthenticationException:print('Login failed: Unauthorized.')returnres=awaitrcon.command('whitelist add{}'.format(user))print(res)rcon.close()© 2020 Ringo Hoffmann (zekro Development)Covered by the Apache Licence 2.0.
Package: asyncredis
asyncredisAn asyncio compatible Redis driver. Just a pet-project.Informationasyncredisis, like I've said above, just a pet-project for me. I really just wanted to experiment with database protocols, and try to write my first database driver!asyncredisinternally connects withasyncio, allowing for asynchronous socket states. It also supports retrying connections. Please DO NOT use this in production. I recommendaioredisfor production usage.InternalsInternally,asyncredisuseshiredisto parse messages that are received from the Redis server.hiredisensures speedy parsing, thanks to being C based.ExamplesIf you do decide to test out this driver for yourself, I'll leave some examples below.importasyncioimportasyncredisasyncdefmain():rds=awaitasyncredis.connect("redis://localhost:6379")awaitrds.set("hello","world")value=awaitrds.get("hello")exists=awaitrds.exists("hello")seralized=awaitrds.dump("hello")awaitrds.delete("hello")print(value)print(exists)print(seralized)awaitrds.close()loop=asyncio.get_event_loop()loop.run_until_complete(main())>>>world>>>True>>>b'\x00\x05world\t\x00\xc9#mH\x84/\x11s'
Package: async-redis-objects
Async Redis ObjectsSome object orient wrappers around the redis interface provided byaioredis.NotesIncluded:hash tablequeue (list)priority queue (sorted set)locks (keys)Includes python implementation with matching interface for mocking.from async_redis_objects.mocks import ObjectClienttested on pypy and CPython 3.6 to 3.9API documentation on read the docsExampleimportaioredisimportasynciofromasync_redis_objectsimportObjectClientasyncdefmain():# Connect with aioredis as normalredis=aioredis.Redis(awaitaioredis.pool.create_pool(address='redis://redis:6379',db=3,minsize=5))# Make an object client object with your redis objectobjects=ObjectClient(redis)# Access a hash table in redistable=objects.hash('hash-table-key')awaittable.set('name','Hello World')# Access a queuequeue=objects.queue('queue-name')awaitqueue.push(awaittable.get('name'))awaitqueue.push(100000)# Access a priority queuepq=objects.priority_queue('other-queue-name')awaitpq.push({'name':'same json serializable object'},priority=100)awaitpq.push(awaitqueue.pop(),priority=101)print(awaitpq.pop())# Print Hello Worldloop=asyncio.get_event_loop()loop.run_until_complete(main())
Package: async-repeat
#AsyncRepeat
A simple decorator for repeating async functions. The main idea is that a coroutine can only be awaited for one time. In
some special case that an async function needs to be run for multiple times, use this tool for an easy approachGet startedFirst install it with pip:pipinstallasync-repeatThen in your program:importasynciofromasync_repeatimportrepeat@repeat(3)asyncdeffoo():print("foo")asyncio.run(foo())The result will be:foo
foo
fooThe repeat decorator has two modes:Concurrent: The function will create tasks and run the tasks at the same timeSynchronous: The coroutines will run one by one
Package: async-repool
async-repoolis a Python library which provides a asyncio-based connection pool management for accessing a RethinkDB database.async-repoolcreates and maintains a configurable pool of active connection to a RethinkDB database. These connections are then available individually through a basic API.Internally, repool uses the PythonAsyncIO Queueclass which is not thread-safe. This means that the same connection pool cannot be share between several threads, please, use asyncio with process workers instead.This is just asyncio-based clone ofrepool.Installationasync-repoolis available as a python library on Pypi. Installation is very simple using pip :$pipinstallasync_repoolThis will installasync-repoolas well as rethinkdb dependency.Basic usageA new connection pool using default connection configurations can simply be created by:fromasync_repoolimportAsyncConnectionPoolpool=AsyncConnectionPool(dict())# Required argument is kwargs for R.connect functionawaitpool.init_pool()conn=awaitpool.acquire()#returns a Connection instanceawaitr.table('heroes').run(conn)#do RethinkDB stuff# ...pool.release(conn)#put back connection to the poolawaitpool.release_pool()#release pool (close rethinkdb connections)# ...asyncwithpool.connect()asconn1:# do something with conn1# pool.release(conn1) is automatically called after leaving the with code blockOptional argumentsAsyncConnectionPoolcreation accepts a number of optional arguments:pool_size: set the pool size, ie. the number of connections opened simultaneously (default=3).connection_ttl: set the connection time to live. Connections older than TTL are automatically closed and re-opened when acquire (default=3600 seconds, set to 0 for disable)
Package: asyncreq
asyncreqasyncreqis a lightweight Python library for making asynchronous HTTP requests usingaiohttp. This library provides two convenient methods for interacting with RESTful APIs in an asynchronous manner.InstallationTo install the library, use the following pip command:pipinstallasyncreqUsagemake_requestThemake_requestmethod allows you to make asynchronous HTTP requests with flexible options. Here's an example of how to use it:fromasyncreqimportmake_requestasyncdefexample_usage():url="https://api.example.com/resource"method="GET"headers={"Authorization":"Bearer YOUR_ACCESS_TOKEN"}try:response_data,status_code,response_headers=awaitmake_request(url=url,method=method,headers=headers,# Add other optional parameters as needed)print(f"Response Data:{response_data}")print(f"Status Code:{status_code}")print(f"Response Headers:{response_headers}")exceptExceptionase:print(f"An error occurred:{e}")requestTherequestmethod is a simplified wrapper aroundmake_requestwith added error handling. It raises appropriate exceptions for common HTTP-related errors:fromasyncreqimportrequest,HTTPExceptionasyncdefexample_usage():url="https://api.example.com/resource"method="GET"headers={"Authorization":"Bearer YOUR_ACCESS_TOKEN"}try:response_data,status_code,response_headers=awaitrequest(url=url,method=method,headers=headers,# Add other optional parameters as needed)print(f"Response Data:{response_data}")print(f"Status Code:{status_code}")print(f"Response Headers:{response_headers}")exceptHTTPExceptionase:print(f"An HTTP error occurred:{e}")Note: make sure to useawaitas demonstrated in the examples above.Dependenciesaiohttp: Asynchronous HTTP client/server framework.ContributingIf you find any issues or have suggestions for improvements, please feel free to open an issue or create a pull request on theGit repository.LicenseThis project is licensed under the MIT license.
Package: async-request
async-requestA lightweight network request framework based on requests & asyncioinstallpipinstallasync_requestusageJust like scrapy:fromasync_requestimportAsyncSpider,RequestclassMySpider(AsyncSpider):start_urls=['https://cn.bing.com/']asyncdefparse(self,response):print(response.xpath('//a/@href').get())yieldRequest('https://github.com/financialfly/async-request',callback=self.parse_github)defparse_github(self,response):yield{'hello':'github'}asyncdefprocess_result(self,result):# Process result at here.print(result)if__name__=='__main__':# Run spiderMySpider().run()For more detailed control (like: handle cookies, download delay, concurrent requests, max retries, logs settings etc.): (refer to the constructor of theCrawlerclass):fromasync_requestimportAsyncSpiderclassMySpider(AsyncSpider):...if__name__=='__main__':MySpider(handle_cookies=True,download_delay=0,concurrent_requests=10,max_retries=3,log_file='spider.log').run()testUsefetchfunction to get a response immediately:fromasync_requestimportfetchdefparse():response=fetch('https://www.bing.com')print(response)if__name__=='__main__':parse()the output will like this:<Response 200 https://cn.bing.com/>Use thetestdecorator is also a method to test spider:importasync_requestasar@ar.test('https://www.baidu.com')defparse(response):print(response.url,response.status_code)if__name__=='__main__':parse()then run the script, you will see the result:https://www.baidu.com/ 200
Package: asyncrequester
Project descriptionAsyncrequester is a library that makes it easy to make async requests with grequests library.Installpip install asyncrequesterQuick startfromasyncrequesterimportget_async_requests,get_single_requestheaders={'authority':'www.google.com','upgrade-insecure-requests':'1','user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36','accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9','sec-fetch-site':'none','sec-fetch-mode':'navigate','sec-fetch-dest':'document','accept-language':'en'}urls=["https://www.google.com"]*100responses=get_async_requests(urls,20,0.5,headers)# it will make 20 requests every 0.5 seconds and return all responses# 'headers' is optionalresponse=get_single_request(urls[0])# it makes simple get requestOutputTotal web page count: 100
0 Waiting
20 Waiting
40 Waiting
60 Waiting
80 Waiting
100 Waiting
Succes: 100 , Fail: 0
It took 7.0120155811309814 seconds to retrieve 100 webpages.Parametersurls:url listmax_connections:max connections at oncetime_delay:delay for every requestheaders:headers(Optinal)