Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 19:45
    dcecile commented #503
  • Jan 31 2019 19:40
    blueyed commented #526
  • Jan 31 2019 13:29
    codecov[bot] commented #526
  • Jan 31 2019 13:26
    codecov[bot] commented #526
  • Jan 31 2019 11:59
    codecov[bot] commented #526
  • Jan 31 2019 11:59
    popravich synchronize #526
  • Jan 31 2019 11:59

    popravich on travis_pypy

    .travis.yml: chaching pip packa… Makefile: build/install only re… .travis.yml: cache redis-server… (compare)

  • Jan 31 2019 11:44
    codecov[bot] commented #526
  • Jan 31 2019 11:36
    codecov[bot] commented #526
  • Jan 31 2019 11:35
    codecov[bot] commented #526
  • Jan 31 2019 11:34
    codecov[bot] commented #526
  • Jan 31 2019 11:24
    codecov[bot] commented #526
  • Jan 31 2019 11:23
    codecov[bot] commented #526
  • Jan 31 2019 10:04
    gyermolenko commented #503
  • Jan 31 2019 09:31
    gyermolenko commented #431
  • Jan 31 2019 09:23
    Natim closed #444
  • Jan 31 2019 09:23
    Natim commented #444
  • Jan 31 2019 09:09
    gyermolenko commented #444
  • Jan 31 2019 05:32
    codecov[bot] commented #539
  • Jan 31 2019 05:32
    vir-mir synchronize #539
001101
@001101
hello
i am running into issues on chia
maybe caused by some of this libs
001101
@001101
Traceback (most recent call last):
File "/usr/lib/python3.7/asyncio/sslproto.py", line 526, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/lib/python3.7/asyncio/sslproto.py", line 207, in feed_ssldata
self._sslobj.unwrap()
File "/usr/lib/python3.7/ssl.py", line 767, in unwrap
return self._sslobj.shutdown()
python 3.7.3 on debian buster
pabloazurduy
@pabloazurduy
Hi guys, I'm testing janus queue to communicate an async process with a sync one, the problem is that at some point the sync process raises exceptions. how to handled them?
import asyncio
import janus


def threaded(sync_q):
    for i in range(100):
        raise Exception('Some custom Exception')
        sync_q.put(i)
    sync_q.join()


async def async_coro(async_q):
    for i in range(100):
        val = await async_q.get()
        assert val == i
        async_q.task_done()


async def main():
    queue = janus.Queue()
    loop = asyncio.get_running_loop()
    fut = loop.run_in_executor(None, threaded, queue.sync_q)
    await async_coro(queue.async_q)
    await fut
    queue.close()
    await queue.wait_closed()


asyncio.run(main())
Thomas Grainger
@graingert
@pabloazurduy what do you want it to do when the exeption happens?
you probably want? await asyncio.gather(async_coro(queue.async_q), asyncio.to_thread(threaded, queue.sync_q))
grubberr
@grubberr
async def handler(request: Request) -> Response:
    url = 'http://internal.api.com'
    async with ClientSession() as session:
        async with session.get(url) as resp:
            ....
Any idea how to mock ClientSession object for writing tests ?
6 replies
graingert
@graingert:matrix.org
[m]
@grubberr: I've never had much luck with pytest-aiohttp - I use:
import pytest
from aiohttp import test_utils

pytestmark = pytest.mark.asyncio

@contextlib.asynccontextmanager
async def aiohttp_client(app):
    async with test_utils.TestClient(test_utils.TestServer(app)) as client:
        yield client

async def test_1():
    app = web.Application()
    ...
    async with aiohttp_client(app) as client:
        ...
you didn't include a traceback or error message with your paste
2 replies
Ben621
@Ben621
hi

I have a question I use the library aioodbc

when i use yield for my cursor (that create async_generator)
i need to use on my second function that consumes this generator it = await cursor.__anext_()
otherwise, it's doesn't work , my question is why? and if i have a way to avoid this

this my code

import asyncio
import aioodbc

async def run_query(query='SELECT 42 AS age;'):
    dsn = 'Driver=SQLite;Database=sqlite.db'

    async with aioodbc.create_pool(dsn=dsn) as pool:
        async with pool.acquire() as conn:
            async with conn.cursor() as cur:
                await cur.execute(quey)
                    yield cur

    async def main(query):
        cursor  =  run_query(qury)
        it = await cursor.__anext_()
        async for row in it:
                   print(row)

if __name__ ==  '__main__':
                asyncio.run(main(query="select 1 as blah")
graingert
@graingert:matrix.org
[m]
@Ben621: why are you yielding it?
Ben621 (Ben621):
import asyncio
import aioodbc


async def run_query(query="SELECT 42 AS age;"):
    dsn = "Driver=SQLite;Database=sqlite.db"

    async with aioodbc.create_pool(
        dsn=dsn
    ) as pool, pool.acquire() as conn, conn.cursor() as cur, cur.execute(quey):
        return list(cur)


async def main(query):
    for row in await run_query():
        print(row)


if __name__ == "__main__":
    asyncio.run(main(query="select 1 as blah"))
Ben621
@Ben621
@graingert:matrix.org your approach doesn't work i got eror
second, i don't want to put it all in the memory list(cur)
that why i use yield
3 replies
graingert
@graingert:matrix.org
[m]
Oh there is an async for
:point_up: Edit: Ben621 (Ben621):
import asyncio
import aioodbc


async def run_query(query="SELECT 42 AS age;"):
    dsn = "Driver=SQLite;Database=sqlite.db"

    async with aioodbc.create_pool(
        dsn=dsn
    ) as pool, pool.acquire() as conn, conn.cursor() as cur, cur.execute(quey):
        async for v in cur:
            yield v


async def main(query):
    async with async_generator.aclosing(run_query()) as it:
        async for row in it:
            print(row)


if __name__ == "__main__":
    asyncio.run(main(query="select 1 as blah"))
@Ben621 fixed the paste
Ben621
@Ben621
@graingert:matrix.org
HI
i'm not familiar with sync_generator.aclosing
from with library it is?
graingert
@graingert:matrix.org
[m]
pip install async_generator
Ben621
@Ben621
@graingert:matrix.org i don't think is a good solution to use a library that the last commit is on Aug 1, 2018
this code work
need to await cur.execute(quey)
import asyncio
import aioodbc

import async_generator


async def run_query(query="SELECT 42 AS age;"):
    dsn = "Driver=SQLite;Database=sqlite.db"

    async with aioodbc.create_pool(
        dsn=dsn
    ) as pool, pool.acquire() as conn, conn.cursor() as cur:
        await cur.execute(quey)
        async for v in cur:
            yield v


async def main(query):
    async with async_generator.aclosing(run_query()) as it:
        async for row in it:
            print(row)


if __name__ == "__main__":
    asyncio.run(main(query="select 1 as blah"))
graingert
@graingert:matrix.org
[m]
It's definitely still maintained @Ben621
https://github.com/python-trio/async_generator is run by the trio team, it's just not needed any changes
Ben621
@Ben621
@graingert:matrix.org
I very appreciate your help
I have a question about my code.
if I use also the for loop inside my function run_query like you did my code work
my question is why I need for loop inside my function and on the other function ? that was i want to use yield on the cursor ,
and that why i was needed to use it = await cursor.__anext_()
i think i missing something
graingert
@graingert:matrix.org
[m]
It would be yield from but that's not valid in async generators
So you need aclosing and async for yield
Ben621
@Ben621

@graingert:matrix.org
sorry I don't understand, why i need the loop in the run_query
instead only to yield the cursor
that doesn't answer
what i'm missing
if I modify your code


async def main(query):
    async with async_generator.aclosing(run_query()) as it:
        async for row in it:
            print(row)

as

async def main(query):
        async for row in  run_query(query=query):
            print(row)

so why i need this
async with async_generator.aclosing(run_query()) as it:
btw i'm using python 3.8

graingert
@graingert:matrix.org
[m]
To make sure your transaction gets closed
Normally you'd pass your pool into run_query though
Ben621
@Ben621
@graingert:matrix.org
ok and what about the for loop
why it's necessary instead to yield the cursor only and pass to loop to another function?
graingert
@graingert:matrix.org
[m]
?
Ben621
@Ben621
@graingert:matrix.org
sorry
why it's necessary to use the for loop inside the run_query and pass to loop to another function? instead to yield the cursor only and iterate on the othe function
graingert
@graingert:matrix.org
[m]
You could make it an @contextlib.asynccontextmanager
Ben621
@Ben621
@graingert:matrix.org i will investigate @contextlib.asynccontextmanager on this thank you very much for your help
Atralupus
@Atralupus
Hi
I want request GET with KSC5601 encoded querystring
How do I this?
Barabba11
@Barabba11
Hi mates! May I kindly ask someone help why I'm receiving 405 Method Not Allowed? Thank you
I'm sending a 4OPTIONS /call/SetCurrentScene HTTP/1.1\r\n (logged out from sniffer), there is maybe something wrong on this request?
lavkush gupta
@lavkushsyncup_gitlab
Hi , I wanted to know if kerberos authentication is supported by aiohttp library? I was checking the code, and it seems like only basic auth is supported. Could someone confirm?
Daniel Alley
@dralley
hello, I have a question. Is FileResponse the only type compatible with HTTP Range requests, and StreamResponse is not compatible?
mendaxi
@mendaxi_twitter
Hi,
I had a question regarding the following exception:
10 replies
Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
Is there any way to catch that error, so it can be ignored (in the case of garbage data just being shoved into the parser)?
Troy P
@tray2100
Hey! I'm very new to aiohttp and python in general but I cobbled together an app using openapi. Everything is working but it seems that all the requests are only getting fulfilled by a single thread. Is there some sort of config/option that I need to pass in to app.run(port=8080) (based on this ) to ensure multiple threads work to fulfill requests?
2 replies
graingert
@graingert:matrix.org
[m]
Show your code? Are you performing blocking IO @tray2100
1 reply
mcepl
@mcepl:matrix.org
[m]
Hi, when packaging aiohttp for openSUSE, I got few tests failing on RuntimeError: Event loop is closed https://da.gd/g1oD Any idea, what’s wrong?
graingert
@graingert:matrix.org
[m]
mcepl: what's the commit hash of the code you're running?
Troy P
@tray2100
@graingert:matrix.org no ... I'm using py-spy to do thread dumps and hitting the server with numerous concurrent GET and POST requests using Apache Benchmark (ab) and I see only a single request handling the incoming requests
mcepl
@mcepl:matrix.org
[m]
graingert: aiohttp-3.7.4.tar.gz from PyPI.
mcepl
@mcepl:matrix.org
[m]
thank you