question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

My first test and it's amazing

See original GitHub issue

I did a little test with a application i have written in FastAPI using SQLAlchemy as ORM and the results are amazing:

The route code is the following:

@router.post('/sync_user')
async def sync_user(login: schemas.Login, db: Session = Depends(get_db)):
    start = datetime.now()
    if user := crud.login.get_by_email(db, login.email):
        end = datetime.now()
        duration = end - start
        logger.info(f'Login Sync Duration: {duration.total_seconds()}')
        return user


@router.post('/async_user')
async def async_user(login: schemas.Login, db: Session = Depends(get_db)):
    start = datetime.now()
    if user := await async_(crud.login.get_by_email)(db, login.email):
        end = datetime.now()
        duration = end - start
        logger.info(f'Login Async Duration: {duration.total_seconds()}')
        return user

Login Sync Duration: 0.015734 Login Async Duration: 0.002904

The results are outstanding

Really thanks for this. I’ll test more later this week.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
miguelgrinbergcommented, Jul 20, 2020

Right, so this does not give you any benefit, you are still blocking. Not sure why your timings say otherwise, but this project isn’t designed to help in your case. You shouldn’t be using SQLAlchemy in an asynchronous application.

0reactions
miguelgrinbergcommented, Jul 20, 2020

The goal is to allow regular and async functions to call each other. There is nothing that makes blocking code non-blocking, at least nothing at this time.

Use cases:

  • use an async library from regular code
  • use an async handler in a non-async web framework such as Flask
Read more comments on GitHub >

github_iconTop Results From Across the Web

The 5 Best Pregnancy Tests of 2022 | Reviews by Wirecutter
The best home pregnancy test. The First Response Early Result wand test is the most sensitive home pregnancy test available in the US....
Read more >
The 6 Best Pregnancy Tests of 2022 | by Verywell Family
The best pregnancy test is accurate, affordable, and easy to use. ... The First Response Early Results kit tops our list with reliable ......
Read more >
What a Positive Pregnancy Test Really Looks Like
What a Positive Pregnancy Test Really Looks Like · The Test: First Response Early Response · The Test: EPT Pregnancy Test · The...
Read more >
Best Pregnancy Tests to Take in 2022 - Babylist
If you just can't wait, the First Response Early Result test is what you want to grab. It's the most sensitive over-the-counter pregnancy...
Read more >
Is Your Positive Pregnancy Test For Real? Find Out Now
First Response Early Result: First Response Early Result was rated as the best pregnancy test. because it was able to detect very low...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found