Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:29
    awemulya commented #213
  • 07:00

    github-actions[bot] on master

    📝 Update release notes (compare)

  • 05:36
    github-actions[bot] commented #2443
  • 05:34
    codecov[bot] commented #2443
  • 05:34
    codecov[bot] commented #2443
  • 05:32
    codecov[bot] commented #2443
  • 05:32
    codecov[bot] commented #2443
  • 05:32
    waynerv synchronize #2443
  • 01:51
    PriyatamNayak commented #1718
  • 01:39
    Mickls edited #2456
  • 01:37
    Mickls opened #2456
  • 01:37
    Mickls labeled #2456
  • 01:06
    dstlny commented #2448
  • 00:51
    dstlny commented #2448
  • 00:51
    dstlny commented #2448
  • 00:28
    Bill-Lathrop commented #2448
  • 00:26
    Bill-Lathrop commented #2448
  • Dec 01 23:44
    github-actions[bot] commented #2431
  • Dec 01 23:43
    tricosmo commented #2431
  • Dec 01 23:43
    codecov[bot] commented #2431
Carlo Mazzaferro
@carlomazzaferro
@Cleptomania not sure if it fits your needs but https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#exclude-from-openapi you can exclude a certain path
Just to note, my models are dynamically generated so I can't manually set the schema_extra in my pydantic models
sreemol-s
@sreemol-s
hi
Valon Januzaj
@vjanz
Guys, how do you ignore alembic directory from mypy?
Andreas Franzén
@triptec
@vjanz ```
[mypy-app.tests.*]
ignore_errors = True
but change the .tests. to .alembic. perhaps
Valon Januzaj
@vjanz
So the tests in this case refers to the directory right
Andreas Franzén
@triptec
yeah
Valon Januzaj
@vjanz
Yes let me try, thank you!
Andreas Franzén
@triptec
actually app.tests represent dirs
so I have app/tests
Valon Januzaj
@vjanz
In my case mypy-src.alembic
Thank you man :)
Andreas Franzén
@triptec
np
Jan Kesten
@janobug_gitlab
Hi there - maybe a noob question: is it normal that an uvicorn started fastapi does only use a singe cpu core?
Timothée Mazzucotelli
@pawamoy
Hi there - weird question on my end... can I run fastapi synchronously? I need to deploy a web service that will handle only one request at a time (to prevent data corruption on disk). I could use another api framework but it would be so much simpler with fastapi/pydantic. Maybe I can just run it through a wsgi server like gunicorn, with a single process?
Nicolas Gilles
@ngilles
@pawamoy that will not solve your problem, if you want to make sure only one request is running at a time, use a lock
Jan Kesten
@janobug_gitlab
I tried different combinations, but what ever I do - one cpu core is 100% busy and the other one just idle. Is that by design?
I saw that I could start uvicorn with --workers - but as I need some huge in memory data structure, this leads to high memory pressure which I would like to avoid.
flapili
@flapili
The ram is cheap in 2020, if you are in a working context explain to your boss the time to learn and use https://docs.python.org/fr/3.8/library/mmap.html is not worse at all
Jan Kesten
@janobug_gitlab
I know mmap - which is what came to my mind already (as old c hacker). But I was wondering if it is 'right' that only one core is used. As for the ram, this is a private project - but data volume is quite huge anyway. I tried some in memory data grid - but it blows up the needed memory too much. Right now it's a numpy array.
Daniel Lassahn
@meteoDaniel
Dear all, I am having a problem with nested asynchronous functions. I receive the well known Message: RuntimeError: This event loop is already running. By adding nest_asyncio.apply() my test's are running but on production the api runs with uvicorn and it does not work anymore. This is because nest_asyncio does not support uvloop. I hope anyone knows the right work around.
Daniel Lassahn
@meteoDaniel

Dear all, I am having a problem with nested asynchronous functions. I receive the well known Message: RuntimeError: This event loop is already running. By adding nest_asyncio.apply() my test's are running but on production the api runs with uvicorn and it does not work anymore. This is because nest_asyncio does not support uvloop. I hope anyone knows the right work around.

I solved this issue by using hypercorn!

Noah
@LoopsGod
hi
I am using SqlAlchemy with db: Session dependency injected
But i keep hitting pool limits
It appears as though it's recreating / adding a new pool on every request
I see this: DEBUG:sqlalchemy.pool.impl.QueuePool:Created new connection <pymysql.connections.Connection object at 0x11e067b50>
on every request
And my application gets stuck upon too many connections
Takashi Futada
@Tafutada_twitter
@janobug_gitlab my understanding is like Node.js, people choose Fast API over Flask or Django, if the app are not CPU bound, just delegating requests to back end services, i.e. I/O bound. Instead if it's CPU bound like training ML models with TensorFlow or something, Fast API async does not make scense.
fastapi-bridge
@fastapi-bridge
[telegram] <THORTHEKINGOFTHUNDER1> https://t.me/joinchat/AAAAAFXzjjgEQ78RfDLOZg
Ryan
@RyanDurk
Not mentioned in the docs: do Query variables have to be a type str? int isn't working. The docs do have an example of float though.
techxonia
@techxonia
delete_objects.png
Follow same things. But get error "An error occurred (NotImplemented) when calling the DeleteObjects operation: Unknown"
What might be the problem? Can anyone tell me the issue that i have?
Jesus Copado Espejo
@jesusce94
Has anyone ever worked with FastAPI using SSE? I'm trying to create a notification system using Server-sent events, although I am not sure how could I implement this
Louis Cha
@LouisJHC
Hi guys! Im trying to migrate AWS lambda and backend APIs to FastAPI + Mangum (Mangum works as an adapter for ASGI applications like the ones you can create with fastAPI so that they can send and receive information from API Gateway to Lambda and vice versa.)
Currently my lambda function set up is like this (main.py):
# Lambda handler
def handler(event, context):
    # if REST call
    if event.get('routeKey', None) == "$default" and 'rawPath' in event: 
        path = event.get('path', None)
        # ... parse other parameters such as method, headers, etc ...
    # else if HTTP call
    elif event.get('path', None):
        path = event.get('rawPath', None)
        # ... parse other parameters such as method, headers, etc ...

    return preprocess_and_call(path, method, headers, query_params, body)

# calls the endpoints after validation, authrization, etc
def preprocess_and_call(path, method, headers, query_params, body):
     try:
         if path in endpoints_list:
            endpoint_to_call = endpoints_list[path]
            # ... validation logics here ...
            response = endpoint_to_call(path, method, headers, query_params, body)
            return response
     except Exception as ex:
            ... return error ..
basically all lambda handler function does is to classify the calls into REST or HTTP and call the preprocess_and_call to authroize, validate the call and, inside this method, it will call one of the backend endpoints that look like this:
def sample_endpoint(path, method, headers, query_params, body):
   try:
       id = query_paraams.get('id', None)
       model = SampleModel()
       model.process()
       response_body = model.json()
       return {
          'status_code': 200,
          'body': response_body
       }

   except Exception as ex:
        # ... process exception ...
and then the endpoint processes the request, returns the response
And Ive tried removing handler function because Mangum has a support for REST and HTTP call, and tried using middleware for preprocess_and_call like this:
from routers import router

app = FastAPI()

app.include_router(router)

# Handler for api calls
@app.middleware("http")
async def preprocess_and_call(request: Request, call_next):
    try:
        if path in endpoints_list:
            # ... validation logics here ...

            response = await call_next(request) # calls the endpoints with corresponding path

            # ... process the response ...

   except Exception as ex:
        # ... process exception ...
handler = Mangum(app)
and using router to wrap the sample_endpoint
would this be the correct way of doing this or is there better/correct way?
Jesus Copado Espejo
@jesusce94

Has anyone ever worked with FastAPI using SSE? I'm trying to create a notification system using Server-sent events, although I am not sure how could I implement this

If SSE is not supported by FastAPI, what other options do I have to create a notification system for my app? If I wanna have some background tasks running on the backend, how can I send the response to the client after backend task finishes?

flapili
@flapili
You can use websocket
Astor Ayestas
@AstorAyestas
Hi everyone, someone used uvicorn with ssl certificades i was trying to use this solution: $ uvicorn example:app --port 5000 --ssl-keyfile=./key.pem --ssl-certfile=./cert.pem but not work for me in windows using mkcert for development key and cert