oremanj / greenback Goto Github PK
View Code? Open in Web Editor NEWReenter an asyncio or Trio event loop from synchronous code
Home Page: https://greenback.readthedocs.io/
License: Other
Reenter an asyncio or Trio event loop from synchronous code
Home Page: https://greenback.readthedocs.io/
License: Other
Hi,
The problem is describe here.
Somehow, I found greenback makes the sync code can interact with async code in async context. My 2nd attempts somehow works out, but the queue is not limited to 1, which set as max_size.
Also, is there any recommendation for my example code. It really messed up to get result from in-thread event loop.
Currently it crashes with a sniffio.AsyncLibraryNotFound exception.
For example this state is attainable within an asyncio FD reader callback (loop.add_reader
). sniffio still reports "asyncio" in this case but greenback is not usable. We should catch the RuntimeError in has_portal and return false.
In our latest release at Prefect, we added greenback
as a dependency and noticed that it is not available on conda-forge or other channels, which definitely presents a challenge for us.
Would it be possible to consider creating a Conda package for greenback
and hosting it on conda-forge?
We would also be happy to assist or contribute to this process, in terms of writing the recipe.
Thanks for your time!
Thanks for the library!
Prefect has been doing some experimenting with greenback here and ran into this limitation because SQLAlchemy is also used:
Unfortunately using greenback alongside sqlalchemy is not possible at this time. If the ephemeral application is running in the same thread as one in which we need to use greenback, then greenback and sqlalchemy will accidentally "mix" messages and crash each other.
The workarounds for this such as running in a separate thread have their own drawbacks
Is this kind of isolation something that could be handled at the greenback
level? Or is this more of a limitation of the way greenlets and/or SQLAlchemy works?
Hi,
I am trying to port synchronous python code to asynchronous with the minimum amount of effort. This code contains about thousand functions with thousand calls which make it annoying to properly port as this requires adding async
/await
keywords everywhere.
greenback
framework looks like to be exactly what i need. I've tested it using asyncio
and that fulfills my needs.
However i want to use this not with trio
or asyncio
but with cocotb
which is also an asynchronous IO framework but running in a special HDL simulator, in this case moselsim
/questasim
. This is for embedded electronics development on FPGAs.
When using greenback
as described in the documentation i get the early complaint that it is not supported.
I am wondering how much effort it is to enable support of a new asynchronous IO framework for greenback
and what that means exactly. I would assume cocotb
is very closely related to asyncio
but that's only an assumption.
cocotb
documentation/sources can be found here:
https://www.cocotb.org/
https://github.com/cocotb/cocotb
If you can provide some help would be very useful.
Thanks
Nicolas
bestow_portal()
runs the first step of greenback_shim
synchronously, which captures greenlet.getcurrent()
as the "parent" greenlet. If bestow_portal()
is run from another task that is already using greenback, this has the effect of forcing the bestowed-upon task to run using the calling task's contextvars.Context
. We should delay the greenlet.getcurrent()
call until at least the second _greenback_shim
step, in order to make sure we're executing it in the new task's context.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.