Open kdcokenny opened 2 weeks ago
I like this feature. I need to think a bit about the possibilities before discussing best approaches
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.
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:
Separate Synchronous Classes
SyncFastCrud
class andsync_crud_router
instanceDual Function Approach (Similar to Langchain)
create
for sync andacreate
for asyncSession
orAsyncSession
Artificial Session Wrapper
Session
s intoAsyncSession
srun_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.