You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Service API is currently totally agnostic to whether things are trio/asyncio. This is good.
The Manager API is also totally agnostic to whether things are trio/asyncio, however you do have to use the right manager for any given async framework. Basically, ignoring how you acquire a manager instance, the same code can work with both asyncio/trio.
The running of services is not agnostic. You're required to pick run_asyncio_service or run_trio_service. Same with backgorund_asyncio_service and background_trio_service.
It would be ideal to expose simple run_service and background_service APIs that could be used in either async framework.
How can it be fixed
I think we can pretty easily use sniffio to create these generic apis. I'm not seeing an obvious downside and sniffio is an incredibly simple and small library.
The text was updated successfully, but these errors were encountered:
Thank you for your suggestion. Using sniffio to implement generic run_service and background_service methods is indeed a great idea. By leveraging sniffio, we can create APIs that are agnostic to whether the underlying async framework is trio or asyncio.
With sniffio, we can detect the currently running async framework and dynamically choose the appropriate implementation for running services. This would allow developers to write code that works seamlessly with both trio and asyncio without having to worry about the specific framework being used.
I will definitely consider this approach and explore the possibilities of implementing it in the Ethereum codebase. Thank you for bringing this to my attention!
What is wrong
The
Service
API is currently totally agnostic to whether things aretrio/asyncio
. This is good.The
Manager
API is also totally agnostic to whether things aretrio/asyncio
, however you do have to use the right manager for any given async framework. Basically, ignoring how you acquire amanager
instance, the same code can work with bothasyncio/trio
.The running of services is not agnostic. You're required to pick
run_asyncio_service
orrun_trio_service
. Same withbackgorund_asyncio_service
andbackground_trio_service
.It would be ideal to expose simple
run_service
andbackground_service
APIs that could be used in either async framework.How can it be fixed
I think we can pretty easily use
sniffio
to create these generic apis. I'm not seeing an obvious downside andsniffio
is an incredibly simple and small library.The text was updated successfully, but these errors were encountered: