snowflake-connector-python icon indicating copy to clipboard operation
snowflake-connector-python copied to clipboard

support for asyncio

Open jpassaro opened this issue 8 years ago • 51 comments
trafficstars

The Snowflake connector for python seems to be implemented essentially as API calls over HTTP. Using aiohttp, companion subclasses to SnowflakeConnector, SnowflakeCursor, SnowflakeRestful etc, could be created that implement the key methods as asynchronous coroutines. Then asyncio tools could be used to run Snowflake connection routines alongside other I/O-centric or API-driven tasks.

Has this been considered? Is it a viable addition to the Snowflake Connector? If so I'm happy to contribute, I'd love to hear any requirements you folks might have in mind. Or on the other hand, is it more appropriate as a fork, or as a separate project altogether in the style of aiobotocore?

jpassaro avatar Oct 24 '17 16:10 jpassaro

Thanks for suggestion. Yes, we considered aiohttp as well as any async feature in 3.4+. There are two concerns: 1) since the driver needs to support both 2.7+ and 3.4+, it may need to have a branch for 3.4+, 2) it is not clear how to handle OCSP check in aiohttp.

OCSP check is a requirement from our security team, though the standard Python's SSL library doesn't support it (and even most other clients don't care about the certificate revocation status!). We use a monkey patch on the top of https://github.com/requests/requests to intercept SSL handshake and add the OCSP checks.

So definitely all contribution would be pleased along with the above concerns addressed.

smtakeda avatar Oct 24 '17 18:10 smtakeda

Checking if there has been any progress with asyncio support for this package, the last update seems to be over 2 years ago..

szelenka avatar May 31 '19 18:05 szelenka

sorry we didn't have enough bandwidth to work on this. A plan is add async support after dropping python2.

smtakeda avatar Jun 03 '19 04:06 smtakeda

Python 2 will stop being supported by the Python Foundation on Jan 1, 2020. Will Snowflake also drop support at that time? Just curious if any timeline has been established on when Snowflake will EOL Python 2 support.

If it helps anyone interested, as a temporary workaround, I've been running Snowflake queries inside a concurrent.futures.ThreadPoolExecutor using what basically amounts to await asyncio.get_event_loop().run_in_executor(...).

This has been just fine for my purposes (internal reporting) and allows me to still use the other neat asyncio features while not blocking the main thread.

krrg avatar Jul 16 '19 23:07 krrg

For Python 2 support, feel free to discuss in #107. We have not decided when we are going to drop Python 2 support yet. Good new is the tread of Python 2 download is down: https://pypistats.org/packages/snowflake-connector-python

We'll keep eyes on the usage metrics on our end to determine the timing of Python2 drop.

smtakeda avatar Jul 19 '19 18:07 smtakeda

We want this for Snowflake: https://github.com/MagicStack/asyncpg https://github.com/aio-libs/aiomysql

smtakeda avatar Aug 10 '19 15:08 smtakeda

What's the progress on aio support? Anything that uses it, such as sqlalchemy-aio cannot take advantage of this dialect+driver without it...

farvour avatar Oct 16 '19 01:10 farvour

Not much progress. In the planning meeting.

smtakeda avatar Oct 19 '19 01:10 smtakeda

Thanks for suggestion. Yes, we considered aiohttp as well as any async feature in 3.4+. There are two concerns: 1) since the driver needs to support both 2.7+ and 3.4+, it may need to have a branch for 3.4+, 2) it is not clear how to handle OCSP check in aiohttp.

Python 2.7 will be deprecated since Jan 1 2020. ANy progress on async SnowFlake connector?

mvoitko avatar Dec 09 '19 12:12 mvoitko

Commenting here to re-emphasise the issue. We are going to use asyncio in ongoing projects involving Python, and not having support for async is a bit frustrating. Are there any news regarding this? Thanks.

islobodch avatar Mar 30 '20 04:03 islobodch

It is very important for snowflake to support the async connector. Otherwise, we have to workaround. It is a big bottleneck for performance optimization. Thanks.

jimfang avatar Apr 05 '20 12:04 jimfang

Hey Everyone, just wanted to bump this feature request. With FastAPI becoming more and more utilized in the python ecosystem, support for an Asyncio continues to become more important. Thanks!

samstiyer avatar Dec 15 '20 12:12 samstiyer

Bump!! We need asyncio support :)

madhukar01 avatar Feb 01 '21 12:02 madhukar01

Please implement pgsql wire protocol for Snowflake. Hard must.

whardier avatar Feb 15 '21 00:02 whardier

I think what Snowflake would really benefit from is some sort of publicly documented HTTP/REST API. It would be a lot easier to build an asyncio community library on top of something that is documented than trying to reverse engineer it or come up with sub-optimal solutions.

krrg avatar Feb 15 '21 02:02 krrg

Snowflake is the primary database for a project I am working on. It has been an absolute struggle dealing with all of the gotchas. Having some visibility would be a good idea - however I am going to assume the security team would struggle with this. Definitely sold to our CTO as very much compatible with existing workflows, tech stacks, etc... and showed a lot of promise by offering an sqlalchemy driver.

I have been mostly using usql (https://github.com/xo/usql) to fill in a lot of gaps with the web ui, the almost unusable cli offered by snowflake, and to act as a system call when I need something done async without having to deal with busted multiprocessing solutions.

whardier avatar Feb 15 '21 02:02 whardier

Next bump. Building a FastAPI application which needs to perform sync and async queries would be much better if the snowflake connector would support asyncio. Yes the sqlalchemy connector is supporting this but lacking snowflake exclusive features like execute_async.

@keller00 are there any updates?

dennis-weyland-by avatar Mar 18 '21 11:03 dennis-weyland-by

I'm sorry, but this is not planned for anytime soon. Our codebase is built upon using urllib3 and other dependencies that use it under the hood (boto3 comes to my mind immediately). We also monkey patch our own OCSP verification into urllib3 for extra security. Last time I checked urllib3 said that they will not support asyncio ever, so to support it we'd need a complete rewrite of the library, which we have tried, but the benchmarks didn't live up to our standards unfortunately.

However; we do as of recently support our own Async execution feature, see documentation here: https://docs.snowflake.com/en/user-guide/python-connector-example.html#label-python-connector-asynchronous-query-examples I hope that this could be useful for some of you!

sfc-gh-mkeller avatar Mar 19 '21 06:03 sfc-gh-mkeller

While the async feature is neat.. it does not offer async socket support.

Perhaps the team at snowflake can look into using httpx as a base.

On Thu, Mar 18, 2021 at 10:05 PM Mark Keller @.***> wrote:

I'm sorry, but this is not planned for anytime soon. Our codebase is built upon using urllib3 and other dependencies that use it under the hood (boto3 comes to my mind immediately). We also monkey patch our own OCSP verification into urllib3 for extra security. Last time I checked urllib3 said that they will not support asyncio ever, so to support it we'd need a complete rewrite of the library, which we have tried, but the benchmarks didn't live up to our standards unfortunately.

However; we do as of recently support our own Async execution feature, see documentation here: https://docs.snowflake.com/en/user-guide/python-connector-example.html#label-python-connector-asynchronous-query-examples I hope that this could be useful for some of you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snowflakedb/snowflake-connector-python/issues/38#issuecomment-802581703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKRFPLDZ7QPXZYNR3SGXTTELSRLANCNFSM4EAS4B5A .

--

[image: --]

Shane R. Spencer [image: https://]about.me/ShaneSpencer https://about.me/ShaneSpencer?promo=email_sig

whardier avatar Mar 19 '21 07:03 whardier

Why support python at all if you can't invest the time and effort to support modern Python?

allenhumphreys avatar Aug 20 '21 14:08 allenhumphreys

Async Python is Future Python, not Modern Python. A lot of widely used libraries are not (yet) async compatible and most Python running in the real world is not async. Don't be silly.

Lexicality avatar Aug 20 '21 16:08 Lexicality

Hi, I'm from the future! 🛸

allenhumphreys avatar Aug 20 '21 17:08 allenhumphreys

Aww sweet! I am not the only modern time traveler.

whardier avatar Aug 21 '21 02:08 whardier

this is a MUST we use snowflake on top of async python to provide customer facing dashboards and it basically slows down our service dramatically there's no new python project that starts without asyncio please prioritize this!

liorchen avatar Oct 12 '21 06:10 liorchen

Any updates?

shahargl avatar Oct 26 '21 08:10 shahargl

Bump

samstiyer avatar Oct 26 '21 13:10 samstiyer

hi guys! for what its worth I've hacked together a nodejs server that I use as proxy with python's aiohttp it works very well https://github.com/varos-io/snowflake-proxy/

liorchen avatar Oct 26 '21 14:10 liorchen

+1 This is pretty critical for us, our entire backend is python asyncio

Looking at writing a threading based async/await wrapper similar to https://github.com/aio-libs/aioodbc

awm33 avatar Nov 10 '21 19:11 awm33

any updates ?

dapollak avatar Dec 30 '21 14:12 dapollak

Hey, I'm from the future 👾, we live on Mars, ETH is the main currency, we resurrected dinosaurs. But there is still no support for the async SF connector...

Any updates? 👀

kchojn avatar Jan 04 '22 18:01 kchojn