Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Антон Касимов
    @toxadx
    I have a proposal for uvicorn. I think that --forwarded-allow-ips shall allow subnet specification. I would like to create a feature request. Any positive feedback?
    Vishal Bollu
    @vishalbollu
    Hi, is there a way to detect abandoned requests and discard them? I am trying to avoid spending unnecessary time on requests from disconnected clients. A client may be disconnected due to browser refreshes, client process exiting or timeouts somewhere in the network. For my use case, the requests are typical REST post requests (not streaming). I came across this blog and found it to be an interesting approach even if it is a bit dated.
    1 reply
    Alexandre Flament
    @dalf
    Do it make sense to have httpcore.CloseError: [Errno 104] Connection reset by peer coming from https://github.com/encode/httpcore/blob/4b662b5c42378a61e54d673b4c949420102379f5/httpcore/_backends/asyncio.py#L198 (using h2, python 3.8.8 with uvloop)? I will try to find a repeatable test case if possible.
    Rafał Pitoń
    @rafalp

    I've got fed up with SQLAlchemy's verbosity, and I've started writing dumb active-record lib that follows pattern:

    users = ActiveRecord(database, users_table, User)
    top_active_users = await users.filter(is_ranked=True).order_by("-score")[:50]

    I'm curious how far I can get before I'll get fed up by basically re-inventing Django ORM :D

    Alex Grönholm
    @agronholm
    Django's ORM is one of the biggest reasons why I steer clear of it
    I've encountered the ActiveRecord pattern long ago and SQLAlchemy freed me from that
    Rafał Pitoń
    @rafalp
    Good for you ;)
    Asger Hautop Drewsen
    @Tyilo
    Is it possible to do a https request with httpx, while specifying the ip address (like curl --resolve), but still send the correct SNI?
    Asger Hautop Drewsen
    @Tyilo
    I got it to work by patching socket.getaddrinfo, but that is a very hacky solution
    Handsomefjc
    @Handsomefjc
    padplus always timeout
    euri10
    @euri10:matrix.org
    [m]
    anyone can refresh my memory on middleware stacking ? I'm using asgi opentelementry one, if I need span context from this middleware in another one I', creating, I should put it before of after this one?
    euri10
    @euri10:matrix.org
    [m]
    ok it's like an onion
    Matt Kafonek
    @kafonek
    minor comment on the python-httpx.org docs -- I don't know how the search works behind the scenes, but it might be worth looking at whether there's any easy search tokenization options built into it? I remembered having an .is_error method but wanted to find docs on it, and didn't get results for .is_error or resp.is_error. I did eventually find the section, which used response.is_error in its example. My previous searches didn't hit on the partial match
    Marc
    @nevermorefu_gitlab
    Is there any better documentation for JSONResponse? I would think that there is a simple way to get the json data in Python. For example return JSONResponse(json_info) then when I call said function and to get the json, I have to decode and load it: data_json = json.loads(response.body.decode()).
    Vytautas Liuolia
    @vytas7

    <ad>
    A new ASGI framework has been released!

    • Compatible (and tested in CI to verify that compatibility) with popular ASGI servers such as encode's Uvicorn, Daphne and Hypercorn.
    • No mandatory external dependencies on any 3rd party package.
    • WebSocket support.
    • multipart/form-data support for both WSGI and ASGI.

    Okay, the framework is, itself, not new :smiling_imp: But we have now added ASGI support in 3.0, in parallel to the existing WSGI framework. The code is shared between the two flavours where feasible.
    </ad>

    Matt Gilene
    @mdgilene
    I need some help. I am running a uvicorn/fastapi app. Inside the "startup" event I create several infinite background tasks using loop.create_task. However, when sending the server a KeyboardInterrupt the server process exits however it appears as though the background tasks are not being killed since the app does not release control of the terminal. The only way to fully exit is to send the PID a kill signal.
    I don't know if it matters but the background tasks are essentially running a confluent-kafka-python consumer loop. I.e.
    while True:
        msg = consumer.poll(1)
        # ... processs messages
    parity3
    @parity3
    Anyone here know if pycurl always uses binary mode when uploading FTP files? I know that it's possible to use the -X command to "hack" the actual RETR/STORE command preamble but I'd prefer not to go down that route
    I want to know if it always sends TYPE I before the STOR.. I guess I'll start looking at source, google/docs aren't helping
    curl tool docs says there's a -B switch to enable ascii, so I guess I can be pretty confident that libcurl is the same way; always binary, does not try to detect mimetype via file extension, etc
    parity3
    @parity3
    Looks like binary is the default, and the same behavior as if it was forced via adding ;type=I in url, so I'm good here, to whom it may concern, so no mime-guessing:
        case 'I': /* binary mode */
        default:
          /* switch off ASCII */
          data->state.prefer_ascii = FALSE;
          break;
        }
    parity3
    @parity3
    @mdgilene I don't know about solving the shutdown semantics but I can spot one issue:
    consumer.poll() halts the loop so nothing else will run for that full second. So you'll either need to convert that to use async-native code or you'll need to run those background tasks in an actual thread pool.
    1 reply
    AmericanY
    @AmericanY
    import requests
        with requests.Session() as req:
            req.auth = authdata
            req.headers.update({
                'x-amz-access-token': access
            })
    
            r = req.get(
                'https://sellingpartnerapi-na.amazon.com/orders/v0/orders/', params=params)
            print(r)
    works fine.
    but for
    async with httpx.AsyncClient(timeout=None) as client:
            client.auth = authdata
            client.headers.update({
                'x-amz-access-token': access
            })
            r = await client.get('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/', params=params)
            print(r)
    it's giving AttributeError: 'URL' object has no attribute 'decode'
    AmericanY
    @AmericanY
    @florimondmanca any help would be much appreciated .
    AmericanY
    @AmericanY
    AmericanY
    @AmericanY
    what the main reason for this error ProxyError("can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE")
    i didn't get the concept of it yet.
    am using http proxy with tunnel mode to access https websites
    i try/except the error. and once i return the request. it's pass without issues. but why?
    this is how i set it
    proxies = httpx.Proxy(
        url="http://x.x.x.x:13010",
        mode="TUNNEL_ONLY",
    )
    chimokosmo
    @chimokosmo
    heyyy guys i wanted to ask that did u have problem with residental proxy
    im getting 407 status code
    with a lot of providers
    szeleeteo
    @szeleeteo

    Uvicorn can only use click package version 7.* as defined in setup.py

    minimal_requirements = [
        "click==7.*",
        ...
    ]

    However, there is currently a pre-release version 8.0.0a1 which fixes many issues

    Would like to request for uvicorn to relax the upper bound for click requirement, such that user can optionally use click version 8 if applicable

    minimal_requirements = [
        "click>=7.*"
        ...
    ]
    2 replies
    John Doe
    @johndoe46

    Hello people,

    (Sorry if it's not the right place to ask)

    I'm currently evaluating starlette through fastapi in order to eventually replace django for some apps. However we need to remain compatible with some SAML implementations (apache/mod_shib). Long story short, is there any starlette equivalent of django's request.META ? I know Starlette has a Request object but it's not clear to me if this object exposes env vars per request when using Starlette behind mod_proxy.

    Thank you,

    John Doe
    @johndoe46
    Answering my own question: everything is available under request.headers
    AmericanY
    @AmericanY
    httpx is sending the value of authorization wrongly.
    'authorization': '[secure]'
    Marcelo Trylesinski
    @Kludex
    Besides the two watcher classes (watchdog and the other I forgot), do you think it makes sense adding something like: https://github.com/breuleux/jurigged ?
    Charles
    @drpyser:matrix.org
    [m]
    Hi people!
    Wondering if uvicorn supports HTTP/1.1 chunked requests, for e.g. large file uploads?
    Francesco Bartoli
    @francbartoli

    Hi all, I'm getting a strange behaviour requesting a GET to a private server which returns a status code 406 with httpx while using requests a 200 response is coming. Same endpoint, same headers with an authorization token:

    In [1]: import httpx
    
    In [2]: res = httpx.get('<private URL>', headers={'content-type': 'application/json', 'authorization': 'Bearer <token>'})
    
    In [3]: print(res.status_code)
    406
    
    In [6]: print(res.request.headers)
    Headers({'host': 'xxxx.xxx.org', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.17.1', 'content-type': 'application/json', 'authorization': '[secure]'})
    In [1]: import requests
    
    In [2]: res = requests.get('<private URL>', headers={'content-type': 'application/json', 'authorization': 'Bearer <token>'})
    
    In [3]: print(res.status_code)
    200
    
    In [4]: print(res.request.headers)
    {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'authorization': 'Bearer <token>'}

    I'm totally stucked on this, any suggestion is well appreciated

    1 reply
    Typhon
    @Typhon66
    I'm seeing some weird logging output from uvicorn, has anyone seen this before?
    ←[32mINFO←[0m:     Started server process [←[36m20712←[0m]
    ←[32mINFO←[0m:     Waiting for application startup.
    ←[32mINFO←[0m:     ASGI 'lifespan' protocol appears unsupported.
    ←[32mINFO←[0m:     Application startup complete
    ←[32mINFO←[0m:     Uvicorn running on ←[1mhttp://127.0.0.1:8000←[0m (Press C TRL+C to quit)
    ←[32mINFO←[0m:     Shutting down
    ←[32mINFO←[0m:     Finished server process [←[36m20712←[0m]
    i'm assuming im missing some kind of dependency for formatting or colors?
    i used the pip install uvicorn[standard]
    Typhon
    @Typhon66
    hmm, looks like its a colors thing, if i use --no-use-colors it's fine, but which dependency do i need to get the colors?
    ok so further looks like if i don't use git bash the colors work fine, but i'd like to use gitbash, i tried setting colors to xterm-256color, but no luck