Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Engine Support #122

Open
kdcokenny opened this issue Jul 5, 2024 · 3 comments
Open

Sync Engine Support #122

kdcokenny opened this issue Jul 5, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@kdcokenny
Copy link
Contributor

Feature Request: Support for Synchronous Database Sessions

Is your feature request related to a problem?

No, this is a new feature proposal.

Proposed Solution

I'd like to discuss options for integrating support for synchronous database sessions. I'm open to implementing this myself, but I'd appreciate opinions on the best approach. Here are some potential solutions I've considered:

  1. Separate Synchronous Classes

    • Create new SyncFastCrud class and sync_crud_router instance
    • Drawback: This would introduce significant code redundancy
  2. Dual Function Approach (Similar to Langchain)

    • Introduce separate functions for sync and async operations
    • Example: create for sync and acreate for async
    • Implementation: Check if the passed db is a Session or AsyncSession
  3. Artificial Session Wrapper

    • Create a wrapper to convert sync Sessions into AsyncSessions
    • Use run_in_threadpool (which FastAPI would do internally for the previous two proposals)

I'm open to other ideas and would appreciate any feedback or alternative suggestions.

@kdcokenny kdcokenny added the enhancement New feature or request label Jul 5, 2024
@igorbenav
Copy link
Owner

igorbenav commented Jul 9, 2024

I like this feature. I need to think a bit about the possibilities before discussing best approaches

@kdcokenny
Copy link
Contributor Author

Yes, I agree. I think the most "FastAPI" solution would be to keep the entire sync process synchronous as fastapi will automatically run that in the thread pool and will ensure that no extra "magic" is occurring behind the hood.

@VDuchauffour
Copy link

@igorbenav Any news on this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants