Saravanan666/pypi-org huggingface dataset:
Package: async-responses
Async ResponsesAsync Responses is a library providing an easy way to mock aiohttp responses inspired byaioresponses.InstallationLibrary is available on PyPi, you can simply install it usingpip.$pipinstallasync-responsesUsageAs an instancear=AsyncResponses()ar.get(...)As a context managerwithAsyncResponses()asar:ar.get(...)With dict as handlerPassing dict ashandlerargument to async-responses would result in it being
returned as a JSON payload.importaiohttpfromasync_responsesimportAsyncResponsesasyncdeftest_response():ar=AsyncResponses()payload={'status':'ok'}ar.get('http://mock.url','/v1/status',handler=payload)asyncwithaiohttp.ClientSession()assession:response=awaitsession.get('http://mock.url/v1/status')assertawaitresponse.json()==payloadWith exception as handlerCalling Async Responses with an exception ashandlerargument would result in
it being raised.importaiohttpfromasync_responsesimportAsyncResponsesimportpytestasyncdeftest_response():ar=AsyncResponses()ar.get('http://mock.url','/v1/status',handler=ZeroDivisionError)withpytest.raises(ZeroDivisionError):asyncwithaiohttp.ClientSession()assession:awaitsession.get('http://mock.url/v1/status')With string as handlerimportaiohttpfromasync_responsesimportAsyncResponsesasyncdeftest_response():ar=AsyncResponses()payload='ok'ar.get('http://mock.url','/v1/status',handler=payload)asyncwithaiohttp.ClientSession()assession:response=awaitsession.get('http://mock.url/v1/status')assertawaitresponse.text()==payloadWith callable as handlerimportaiohttpfromasync_responsesimportAsyncResponsesasyncdeftest_response():defhandler(data,**kwargs):return{'status':'ok'}ar=AsyncResponses()ar.get('http://mock.url','/v1/status',handler=payload)asyncwithaiohttp.ClientSession()assession:response=awaitsession.get('http://mock.url/v1/status')assertawaitresponse.json()=={'status':'ok'}With a custom status codeimportaiohttpfromasync_responsesimportAsyncResponsesasyncdeftest_response():payload={'status':'not good'}ar=AsyncResponses()ar.get('http://mock.url','/v1/status',handler=payload,status=500)asyncwithaiohttp.ClientSession()assession:response=awaitsession.get('http://mock.url/v1/status')assertresponse.status==500assertawaitresponse.json()==payloadWith a custom response classasync-responses will make use of a response class passed as an argument to
ClientSession, so you can use things like custom JSON serializer.importaiohttpasyncdeftest_response():classCustomResponse(aiohttp.ClientResponse):asyncdefjson(self,*args,**kwargs):return{'hello':'world'}ar=AsyncResponses()ar.get('http://mock.url','/v1/status',handler='')asyncwithaiohttp.ClientSession(response_class=CustomResponse)assession:response=awaitsession.get('http://mock.url/v1/status')assertawaitresponse.json()=={'hello':'world'}assertisinstance(response,CustomResponse)
Package: async_retrying
info:Simple retrying for asyncioInstallationpipinstallasync_retryingUsageimportasynciofromasync_retryingimportretrycounter=0@retry@asyncio.coroutinedeffn():globalcountercounter+=1ifcounter==1:raiseRuntimeError@asyncio.coroutinedefmain():yield fromfn()loop=asyncio.get_event_loop()loop.run_until_complete(main())assertcounter==2loop.close()Python 3.3+ is required
Package: async-retrying-ng
async_retryingNext Gen. simple retrying for asyncio - fork/fix fromhttps://GitHub.com/hellysmile/async_retryingbut updated for Python 3.10+ onlyInstallationshellpip install async_retrying_ngUsagepythonimport asyncio

    from async_retrying_ng import retry

    counter = 0

    @retry
    async def fn():
        global counter

        counter += 1

        if counter == 1:
            raise RuntimeError

    async def main():
        await fn()

    loop = asyncio.get_event_loop()

    loop.run_until_complete(main())

    assert counter == 2

    loop.close()Python 3.10+ is required
Package: async-rmq
ОглавлениеОписаниеУстановка и запускОписаниеВ данной библиотеке реализовано взаимодействие с асинхронной библиотекой RabbitMQ (создание очередей, точек обмена, абстрактный класс для консюмеров сообщений)Установка и запускПеред запуском необходимо установитьPythonвместе с pip.Далее необходимо скачать библиотеку с GitLab:git clone https://gitlab.getstream.ru/getstream/r-n-d/rabbitmq-service-pythonОткрыть из корневой папки проекта командную строку и установить библиотеку в python:python setup.py install
Package: async-rotating-proxy
async-rotating-proxyRun an API on your local machine that reroutes traffic through rotating proxies.Excellent for scaling your web scrapingDesigned for page-by-page dynamic proxy switching with pyppeteerInstallationpip install async_rotating_proxyUsagefromasync_rotating_proxyimportProxyAPIimportpyppeteerproxies=[ip:port,ip:port,ip:port]withProxyAPI(proxies)asapi:url=api.format_url("http://checkip.dyndns.org")browser=awaitpyppeteer.launch()page=awaitbrowser.newPage()awaitpage.goto(url)PurposeThe article referenced below sums it up pretty well:
"The chrome browser does not support fain-grained proxy configuration out of the box. Therefore, the following use cases are not possible when using puppeteer in combination with Google Chrome:Using different proxies for different tabs/windows
Switching proxies without restarting the browserThis is a bit annoying, because restarting the entire browser is an expensive operation in terms of computational resources. The chrome restart takes up to two seconds (depending on the system). We ideally want to switch proxies whenever the need arises without restarting the entire chrome process. This is a common requirement when scraping websites in scale."Referencehttps://incolumitas.com/2020/12/20/dynamically-changing-puppeteer-proxies/
Package: async-rundeck
Asynchronous rundeck API clientThis is a rundeck API client implemeneted by aio-http and pydantic.
All API parameters and responses are annotated and user-friendly!Installationpipinstallasync-rundeckHow to useimportasynciofromasync_rundeckimportRundeckasyncdefmain():Rundeck(url=rundeck_service,username="admin",password="admin",api_version=41)project_name=uuid4().hexawaitrundeck.create_project(project_name)job_content=(root_dir/"resource"/"Test_job.xml").read_text()# Import jobstatus=awaitrundeck.import_jobs(project_name,job_content,content_type="application/xml",uuid_option="remove",)iflen(status["succeeded"])!=1:print("Failed to import job")returnjobs=awaitrundeck.list_jobs(project_name)# Execute jobexecution=awaitrundeck.execute_job(jobs[0].id)assertexecutionisnotNoneasyncio.run_until_complete(main())FeaturesThe items checked in the following list are implemented.System InfoList MetricsMetrics LinksMetrics DataMetrics HealthcheckMetrics ThreadingMetrics PingUser ProfileLog StorageExecution ModeCluster ModeACLsJobsList jobRun jobImport job from fileExport job from fileExecutionsGet Executions for a JobDelete all Executions for a JobListing Running ExecutionsExecution InfoUpload files for an Execution.List Input Files for an ExecutionDelete an ExecutionBulk Delete ExecutionsExecution QueryExecution StateExecution OutputExecution Output with StateAborting ExecutionsAdhocKey StorageUpload keysList keysGet Key MetadataGet Key ContentsDelete KeysProjectsListing ProjectsProject CreationGetting Project InfoProject DeletionProject ConfigurationProject Configuration KeysProject Archive ExportProject Archive Export AsyncProject Archive Export StatusProject Archive ImportUpdating and Listing Resources for a ProjectProject Readme FileProject ACLsListing HistoryResources/NodesSCM
Package: async_runner
Async RunnerAsync runner is a thin wrapper over Celery API. This will enable control over failed messages by moving them to separate queue (generally queue_name_error) and also allows to retry the task with the help of retry policy.More can be found at documentation:https://async_runner.readthedocs.orgfromasync_runnerimportasync_runnerasync_runner.send_task(task_fn=func,# task function can be python module pathqueue='queue_name',# name of the queueargs=(arg1,arg2,arg3,),# tuple/list of positional arguments to task functionkwargs={'name':'parameter'},# dictionary with key word arguments to task functionoptions={'max_retries':3,# maximum number of times the task is retried'retry_policy':{'retry_interval':12# interval between retires (in seconds)}})TODO:Decouple from DjangoHistory0.1.0 (2016-1-22)First release on PyPI.0.1.1 (2016-1-22)Fix issues.
Package: asyncsa
asyncsaasyncio sqlalchemy support,with async/awaitadd asyncio sqlalchemy supportInstallpip install asyncsaUsage examplesimportasynciofromsqlalchemyimportInteger,Column,String,ForeignKeyfromasyncsa.manager.async_pgimportPostgresManagerfromasyncsa.model.mixinimportMixinfromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemy.ormimportrelationshipfromsqlalchemy.sqlimportselectdsn="postgres://postgres:test@localhost:2345/test"conf={'dsn':dsn}Base=declarative_base()Manager=PostgresManager(conf=conf)classUser(Mixin,Base):_manager=Manager__tablename__='test'id=Column(Integer,autoincrement=True,primary_key=True)name=Column(String(50))def__repr__(self):return"<User(name='%s', id='%s')>"%(self.name,self.id)classParent(Mixin,Base):__tablename__='parent'_manager=Managerid=Column(Integer,primary_key=True)child=relationship("Child",lazy='joined')classChild(Mixin,Base):_manager=Manager__tablename__='child'id=Column(Integer,primary_key=True)parent_id=Column(Integer,ForeignKey('parent.id'))parent=relationship("Parent",back_populates="child")if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(Manager.connect())result=loop.run_until_complete(Manager.get(User.objects([User.id]).join(Parent.__table__,Parent.id==User.id)))print(result)# result = loop.run_until_complete(Child.create_table())# print(result)# u = loop.run_until_complete(User.create(name='test'))# print('create', u)# print('get', loop.run_until_complete(User.get(name='test')))# print('all', loop.run_until_complete(User.all()))# u.name = 'aaa'# print('save', loop.run_until_complete(u.save()))LicenseThe asyncnsq is offered under APGLV3 license.
Package: async-sabnzbd
async-sabnzbdPython wrapper for SABnzbd APIimportasynciofromasync_sabnzbd.sabnzbdimportSabnzbdasyncdefmain():sabnzbd=Sabnzbd(api_key="mykey",base_url="http://mysabnzbdurl")queue=awaitsabnzbd.queue()print(queue)asyncio.run(main())
Package: async-sched
Use async to have functions run on a schedule.ExampleAsync Sched can run tasks on a schedule. It can also receive new tasks (in limited fashion) and change the running
schedules without stopping the service.scheduler.py
schedules/
    task1.py
    task2.py# scheduler.pyimportasync_schedsrv=async_sched.start_server(('127.0.0.1',8000),update_path='./schedules',global_server=True)# srv.add('3 Second', async_sched.Schedule(seconds=3), print, 'Hello 3 seconds')srv.run_forever()Task 1 in the schedules directory will automatically be imported. Becausestart_serversets the server as an
accessible attribute withget_serverwe can dynamically add schedules.# schedules/task1.pyfromasync_schedimportget_server,Scheduleimportdatetimedefprint_task1():print('Hello! I am task 1 '+str(datetime.datetime.now()))s=Schedule(seconds=30,repeat=True)# This will remove an existing 'Task 1' and schedule a new 'Task 1'server=get_server()server.add('Task 1',s,print_task1)In the task 2 file we are not scheduling any commands, but we are registering a callback function that can be run
from a client later.# schedules/task2.pyfromasync_schedimportget_server,Scheduleimportdatetimeserver=get_server()@server.register_callback# or @server.register_callback('print_task2')defprint_task2(name):print('Task 2 is running! ',name,str(datetime.datetime.now()))Now run the scheduler server to listen to remote commands and manage the running schedules.python scheduler.py# or python -m async_sched.server.run –path “schedules” –host “127.0.0.1” –port 8000Use a client to print the running schedules.python -m async_sched.client.request_schedules –host “127.0.0.1” –port 8000Reload the files in the./schedules/directory.python -m async_sched.client.update server –host “127.0.0.1” –port 8000Stop a schedule that is running.python -m async_sched.client.stop_schedule “Task 1” –host “127.0.0.1” –port 8000Run a registered callback function.python -m async_sched.client run_command “print_task2” “hello” –host “127.0.0.1” –port 8000Schedule a registered command.python -m async_sched.client schedule_command “print_task2” “hello” –seconds 10 –host “127.0.0.1” –port 8000
Package: async-scheduler-object
Async scheduler objectObject-like async schedulerInstallhttps://pypi.org/project/async-scheduler-object/Usageimportasynciofromdatetimeimporttimedeltafromasync_scheduler_objectimportAsyncScheduler,AsyncSchedulerEventclassAgeSchedulerEvent(AsyncSchedulerEvent):def__init__(self,start:int)->None:self._age=startasyncdefrun(self)->None:print("Age",self._age)self._age+=1classCatsSchedulerEvent(AsyncSchedulerEvent):def__init__(self,start:int)->None:self._cats_count=startasyncdefrun(self)->None:print("Cats",self._cats_count)self._cats_count*=1asyncdefmain()->None:scheduler_1=AsyncScheduler(events=[AgeSchedulerEvent(start=1)],interval=timedelta(seconds=1),)scheduler_2=AsyncScheduler(events=[AgeSchedulerEvent(start=10),CatsSchedulerEvent(start=20)],interval=timedelta(seconds=0.5),)awaitscheduler_1.start()awaitscheduler_2.start()awaitasyncio.sleep(10)awaitscheduler_1.stop()awaitscheduler_2.stop()asyncio.run(main())
Package: async-scrape
Async-scrapePerform webscrape asyncronouslyAsync-scrape is a package which uses asyncio and aiohttp to scrape websites and has useful features built in.FeaturesBreaks - pause scraping when a website blocks your requests consistentlyRate limit - slow down scraping to prevent being blockedInstallationAsync-scrape requiresC++ Build toolsv15+ to run.pip install async-scrapeHow to use itKey inpur parameters:post_process_func- the callable used to process the returned responsepost_process_kwargs- and kwargs to be passed to the callableuse_proxy- should a proxy be used (if this is true then either provide aproxyorpac_urlvariable)attempt_limit- how manay attempts should each request be given before it is marked as failedrest_wait- how long should the programme pause between loopscall_rate_limit- limits the rate of requests (useful to stop getting blocked from websites)randomise_headers- if set toTruea new set of headers will be generated between each requestGet requests# Create an instance
from async_scrape import AsyncScrape

def post_process(html, resp, **kwargs):
    """Function to process the gathered response from the request"""
    if resp.status == 200:
        return "Request worked"
    else:
        return "Request failed"

async_Scrape = AsyncScrape(
    post_process_func=post_process,
    post_process_kwargs={},
    fetch_error_handler=None,
    use_proxy=False,
    proxy=None,
    pac_url=None,
    acceptable_error_limit=100,
    attempt_limit=5,
    rest_between_attempts=True,
    rest_wait=60,
    call_rate_limit=None,
    randomise_headers=True
)

urls = [
    "https://www.google.com",
    "https://www.bing.com",
]

resps = async_Scrape.scrape_all(urls)Post requests# Create an instance
from async_scrape import AsyncScrape

def post_process(html, resp, **kwargs):
    """Function to process the gathered response from the request"""
    if resp.status == 200:
        return "Request worked"
    else:
        return "Request failed"

async_Scrape = AsyncScrape(
    post_process_func=post_process,
    post_process_kwargs={},
    fetch_error_handler=None,
    use_proxy=False,
    proxy=None,
    pac_url=None,
    acceptable_error_limit=100,
    attempt_limit=5,
    rest_between_attempts=True,
    rest_wait=60,
    call_rate_limit=None,
    randomise_headers=True
)

urls = [
    "https://eos1jv6curljagq.m.pipedream.net",
    "https://eos1jv6curljagq.m.pipedream.net",
]
payloads = [
    {"value": 0},
    {"value": 1}
]

resps = async_Scrape.scrape_all(urls, payloads=payloads)ResponseResponse object is a list of dicts in the format:{
    "url":url, # url of request
    "req":req, # combination of url and params
    "func_resp":func_resp, # response from post processing function
    "status":resp.status, # http status
    "error":None # any error encountered
}LicenseMITFree Software, Hell Yeah!
Package: asyncselenium
asyncselenium PackageThis is a tools and libraries enabling web browser automation.it makes selenium to be async, and improve the performance!the useage is the same to selenium to make it easy to use.you can simply install or upgrade:pip install -U asyncseleniumif you already make the remote driver running (use the default port 4444):.. code-block:: pythonimport asyncio

from selenium import webdriver
from selenium.webdriver.common.by import By
from asyncselenium.webdriver.remote.async_webdriver import AsyncWebdriver
from asyncselenium.webdriver.support.async_wait import AsyncWebDriverWait
from asyncselenium.webdriver.support import async_expected_conditions as ec

async def test_get():
    chrome_options = webdriver.ChromeOptions()
    browser = await AsyncWebdriver(options=chrome_options)
    wait = AsyncWebDriverWait(browser, 20)
    await browser.get('https://www.baidu.com')
    ele = await wait.until(ec.presence_of_element_located((By.XPATH, '//*[@id="su"]')))
    search = await wait.until(ec.presence_of_element_located((By.XPATH, '//*[@id="kw"]')))
    await search.send_keys('python')
    print(await ele.tag_name)
    await asyncio.sleep(3)
    await browser.quit()

asyncio.run(test_get()).. code-block:: pythonimport asyncio
import sys
sys.path.append('.')
from selenium.webdriver.chrome import service
from asyncselenium.webdriver.chrome.async_webdriver import WebDriver

driver_path = ''
async def test_get():
    browser = await WebDriver(driver_path)
    await browser.get('https://www.baidu.com')
    await asyncio.sleep(5)
    await browser.quit()

async def test_multi_browser():
    service = WebDriver.get_service(driver_path)
    browser = await WebDriver(driver_path, service=service)
    await browser.get('https://www.baidu.com')
    browser2 = await WebDriver(driver_path, service=service)
    await browser2.get('https://news.baidu.com')
    await asyncio.sleep(5)
    await browser.quit(stop_service=False)
    await browser2.get('https://www.baidu.com')
    await asyncio.sleep(5)
    await browser2.quit()

asyncio.run(test_multi_browser())
Package: async-sender
AsyncSender provides a simple interface to set up a SMTP connection and send email messages asynchronously.InstallationInstall with the following commandpipinstallasync_senderQuickstartAsyncSender is really easy to use.  Emails are managed through aMailinstancefromasync_senderimportMailimportasyncioasyncdefrun():mail=Mail()awaitmail.send_message("Hello",from_address="from@example.com",to="to@example.com",body="Hello world!")asyncio.run(run())MessageTo send one message, we need to create aMessageinstancefromasync_senderimportMessagemsg=Message("demo subject",from_address="from@example.com",to="to@example.com")
Package: async-sendgrid
Async-SendgridSendGrid simple async client based on httpx.Installationpipinstallasync-sendgridUsageimportasync_sendgridfromsendgrid.helpers.mailimportContent,Email,Mail,ToimportosAPI_KEY=os.environ.get('API_KEY')from_email=Email("test@example.com")to_email=To("test@example.com")subject="Lorem ipsum dolor sit amet, consectetur adipiscing elit"content=Content("text/plain","Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem.")mail=Mail(from_email,to_email,subject,content)data={"personalizations":[{"to":[{"email":"test@example.com"}],"subject":"Lorem ipsum dolor sit amet, consectetur adipiscing elit",}],"from":{"email":"test@example.com"},"content":[{"type":"text/plain","value":"Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem."}],}# Send email with context managerasyncwithasync_sendgrid.AsyncClient(api_key=API_KEY)asclient:response1=awaitclient.send(data)response2=awaitclient.send(mail)# Send email without context managerclient=async_sendgrid.AsyncClient(api_key=API_KEY)awaitclient.open()response1=awaitclient.send(data)response2=awaitclient.send(mail)awaitclient.close()
Package: asyncserf
asyncserf is an async Python interface to Serf, the decentralised solution
for service discovery and orchestration.It usesanyio <https://github.com/agronholm/anyio>as its underlying
async framework.Installationasyncserf requires a running Serf agent. SeeSerf’s agent documentationfor instructions.To install asyncserf, run the following command:$pipinstallasyncserfor alternatively (you really should be using pip though):$easy_installasyncserfor from source:$pythonsetup.pyinstallGetting StartedThese examples require a running async loop.Trio <https://github.com/python-trio/trio>is recommended, thoughasyncioworks too.Sending a message is easy:from asyncserf import serf_client

async with serf_client() as client:
    await client.event('foo', b'bar')So is receiving:.. code-block:: pythonfrom asyncserf import serf_clientasync with serf_client() as client:async with client.stream(‘foo’) as stream:async for resp in stream:print(resp.payload)DevelopmentYou can run the tests using the following commands:$serfagent--tagfoo=bar&# start serf agent$python3-mpytesttests
Package: asyncserial
============================Asyncio wrapper for pyserial============================.. image:: https://badge.fury.io/py/asyncserial.svg:target: https://badge.fury.io/py/asyncserial:alt: PyPI version.. image:: https://img.shields.io/pypi/pyversions/asyncserial.svg:target: https://pypi.org/project/asyncserial/:alt: Python Versions.. image:: https://readthedocs.org/projects/asyncserial/badge/?version=latest:target: http://asyncserial.readthedocs.io/en/latest/?badge=latest:alt: Documentation Status`asyncserial` is a a wrapper for the `pyserial` library providing an async interface based on `async def` and `await`.Installation============.. code-block:: shpip install asyncserialDocumentation=============https://asyncserial.readthedocs.ioExamples========.. code-block:: pythonimport asynciofrom asyncserial import Serialloop = asyncio.get_event_loop()test_serial = Serial(loop, "/dev/ttyACM0", baudrate=115200)async def test():await test_serial.read() # Drop anything that was already receivedwhile True:line = await test_serial.readline() # Read a lineprint("[+] Serial read: {}".format(line))await asyncio.sleep(0) # Let's be a bit greedy, should be adjust to your needsasyncio.ensure_future(test())print("[+] Starting eventloop")loop.run_forever()