Re: [cx-oracle-users] async
Brought to you by:
atuining
From: Norman D. <den...@gm...> - 2017-10-26 10:39:33
|
Hello Walter, > (We can use cx_Oracle with these frameworks now, but during any calls to the database the code can do nothing else except wait for the answer from the database). Actually, cx_Oracle use the macros Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS to let other threads run during driver calls and database work. So even without an async version of cx_Oracle, you may execute your calls in a “concurrent.futures.ThreadPoolExecutor” Of course it’s not perfect but it allows async code still call non-async code in a non-blocking way. See: https://docs.python.org/3/library/asyncio-eventloop.html#executor <https://docs.python.org/3/library/asyncio-eventloop.html#executor> https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor <https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor> Norman > On 26 Oct 2017, at 10:47, Walter Dörwald <wa...@li...> wrote: > > On 24 Oct 2017, at 19:57, Anthony Tuininga wrote: > >> Hi Andrew, >> >> Apologies for the delay in response. I had a busy month. :-) >> >> There are no current plans to make cx_Oracle "compatible" with asyncio, but >> that could change -- especially if you provided some indication of what you >> meant by that request! It might be useful to create an issue on the >> cx_Oracle issues page providing some more details. That will give others a >> chance to comment a well, since not everyone is on the mailing list. > > I guess this would mean that for each method that talks to the database there should be an async version, i.e. instead of > > def print_foo(): > cursor.execute("select * from foo") > for row in cursor: > print(row) > > we could do: > > async def print_foo(): > await cursor.execute("select * from foo") > async for row in cursor: > print(row) > > Then we could use cx_Oracle with other async frameworks (aiohttp, sanic and probably Tornado and Twisted and a bunch others) and take advantage of cx_Oracle's new async features. > > (We can use cx_Oracle with these frameworks now, but during any calls to the database the code can do nothing else except wait for the answer from the database). > > Details for async/await are in PEP 492 at https://www.python.org/dev/peps/pep-0492/ > >> Anthony >> >> On Mon, Sep 25, 2017 at 10:22 PM, Andrew Zyman <fo...@gm...> wrote: >> >>> Hello, >>> wonder if there are any plans to make the module "compatible" with >>> asyncio ? >>> Thank you >>> AZ > > Servus, > Walter > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |