pony icon indicating copy to clipboard operation
pony copied to clipboard

asyncio + futures support

Open socketpair opened this issue 10 years ago • 41 comments

socketpair avatar Jun 02 '14 19:06 socketpair

+1

FPurchess avatar Sep 10 '14 13:09 FPurchess

+2 :)

klen avatar Jan 24 '15 11:01 klen

+1

sdfsdhgjkbmnmxc avatar Oct 22 '15 19:10 sdfsdhgjkbmnmxc

+1

jie avatar Jan 31 '16 02:01 jie

Bump

msoedov avatar Oct 17 '16 21:10 msoedov

+1

stleon avatar Oct 31 '16 15:10 stleon

+1

pylover avatar Oct 31 '16 16:10 pylover

+1

pasaranax avatar Nov 07 '16 13:11 pasaranax

+1

jammie987 avatar Jan 24 '17 11:01 jammie987

With new async web frameworks such as Sanic, I would love to be able to use this library with the new async/await syntax.

+1

th0mas avatar Mar 26 '17 20:03 th0mas

+1

ziwon avatar Jun 05 '17 08:06 ziwon

+1

cemoody avatar Sep 23 '17 03:09 cemoody

Any news?

nickmetal avatar Jan 16 '18 15:01 nickmetal

+100 ;-)

cypreess avatar Feb 22 '18 12:02 cypreess

+1

pingf avatar Feb 28 '18 02:02 pingf

+1

pawelswiecki avatar Jun 11 '18 18:06 pawelswiecki

+1

anyUesr avatar Jul 22 '18 16:07 anyUesr

+1

cyberbudy avatar Jul 27 '18 06:07 cyberbudy

It would be great to also support trio (an alternative event loop implementation on top of async/await with a much nicer API)

ulope avatar Jan 09 '19 14:01 ulope

https://docs.ponyorm.com/transactions.html#using-db-session-with-generator-functions-or-coroutines is that not enough for now ?

jgirardet avatar Jan 09 '19 16:01 jgirardet

I'd love to give it a spin using trio.

dekoza avatar Apr 17 '19 20:04 dekoza

Any news regarding this?

je111ena avatar Aug 14 '19 15:08 je111ena

+1 Sanic needs

sunshineinwater avatar Feb 12 '20 04:02 sunshineinwater

Ok, so changes that native async needs:

  1. Do not perform blocking IO. That means that you need a new set of database libraries (eg asyncpg).
  2. The asyncness of functions that do IO has to trickle up. So compiling SQL is a CPU-bound task and can still be done the same way. But the functions that send those queries to the database library have to be async, and the functions that glue together the user-facing APIs with the query compiler and the query executors become async, and then the actual public APIs become async.

Honestly, the simpler way is to use the integration of asyncio and concurrent.futures to make async proxies that send the work to a background thread, rather than trying to retool an entire library to be async. Preferably with a heavy dose of metaprogramming.

And no, I don't know of any tools that will allow a single source to act as both sync and async. In theory, you could strip all the async-related keywords, but you still need a way to interact with the libraries you talk to (either by switching libraries or wrapping in a sync-async bridge).

Trust me, I've been down this road, I have my own library that attempts to live in both worlds. It's not great.

AstraLuma avatar Mar 31 '20 18:03 AstraLuma

@astronouth7303 telethon is using own synchronizer for async API to be able to be used as sync lib You should take a look ;)

JuniorJPDJ avatar May 10 '20 17:05 JuniorJPDJ

+2

phacic avatar Sep 24 '20 00:09 phacic

+1

MioYvo avatar Oct 16 '20 09:10 MioYvo

When Pony does not perform blocking IO and start use async/await, will lazy fetch still be usable?

I mean, before thinking modifying Pony. Lazy fetch does conflict with async/await. How can this problem be solved?

Ok, so changes that native async needs:

  1. Do not perform blocking IO. That means that you need a new set of database libraries (eg asyncpg).
  2. The asyncness of functions that do IO has to trickle up. So compiling SQL is a CPU-bound task and can still be done the same way. But the functions that send those queries to the database library have to be async, and the functions that glue together the user-facing APIs with the query compiler and the query executors become async, and then the actual public APIs become async.

Honestly, the simpler way is to use the integration of asyncio and concurrent.futures to make async proxies that send the work to a background thread, rather than trying to retool an entire library to be async. Preferably with a heavy dose of metaprogramming.

And no, I don't know of any tools that will allow a single source to act as both sync and async. In theory, you could strip all the async-related keywords, but you still need a way to interact with the libraries you talk to (either by switching libraries or wrapping in a sync-async bridge).

Trust me, I've been down this road, I have my own library that attempts to live in both worlds. It's not great.

jinCN avatar Dec 30 '20 03:12 jinCN

I'm wondering since the most awesome part of Pony is the SQL query builder if this could be used standalone, so it the resulting queries could be used with an async client? Or someone could build an async Pony by importing the query builder but rebuilding with async in mind?

levrik avatar Feb 26 '21 12:02 levrik

I'm wondering since the most awesome part of Pony is the SQL query builder if this could be used standalone, so it the resulting queries could be used with an async client? Or someone could build an async Pony by importing the query builder but rebuilding with async in mind?

maybe a pure Pony SQL query builder is a key for aio pony

Ed-XCF avatar Apr 14 '21 07:04 Ed-XCF