Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async support #106

Open
ramnes opened this issue Nov 12, 2021 · 10 comments
Open

Async support #106

ramnes opened this issue Nov 12, 2021 · 10 comments

Comments

@ramnes
Copy link

ramnes commented Nov 12, 2021

Hey there, thanks for the neat library.

Do you have any plan to support native async features of Python?

e.g.:

from mixpanel import AsyncMixpanel

mp = AsyncMixpanel(YOUR_TOKEN)

# tracks an event with certain properties
await mp.track(DISTINCT_ID, 'button clicked', {'color' : 'blue', 'size': 'large'})

# sends an update to a user profile
await mp.people_set(DISTINCT_ID, {'$first_name' : 'Ilya', 'favorite pizza': 'margherita'})
@seizethedave
Copy link
Contributor

Hello @ramnes - no, I haven't spent any time thinking about that. It sounds useful as an alternative backend, and if you end up with ideas about how this might look, I'd be happy to work with you on it. As it stands, the test suite for this project is heavily tied to requests which I understand would not be used under an async variant of this library/class. I do have plans to open the design up a bit in the next major version to allow more flexibility - perhaps an async mode could influence that a bit.

@ramnes
Copy link
Author

ramnes commented Nov 16, 2021

Yep, I've seen that you switched to requests recently. That's a missed opportunity because supporting async definitely means using another library. Ideally you want to use a single library for both the sync and async HTTP requests, like encode/httpx.

The codebase here is quite small and I've written multiple sync/async HTTP clients already (most notably notion-sdk-py); I could probably tackle this myself someday if you're interested in such a PR. Are you?

@seizethedave
Copy link
Contributor

@ramnes Let's come back to this once we've nixed Py2 support. Next major vers., which is cooking slowly.

@ramnes
Copy link
Author

ramnes commented Nov 20, 2021

What's the roadmap exactly? I could bring Python 3 idiomatic features as well if you wish. Is there anything in particular that you want to achieve before?

@DimaDDM
Copy link

DimaDDM commented Jan 26, 2023

Hello. I will support this issue. i want to see async support for this library. I have been using it for many years and in connection with the transfer of projects to the asynchronous stack it would be very appreciated

@Kylmakalle
Copy link

I've forked the repo and re-implemented it with aiohttp
https://github.com/Kylmakalle/mixpanel-python-asyncio. Available for Python 3.7+.

I've rewritten the tests to asyncio as well, so It should be safe enough to install.

Release 1.0.0

Install

pip install https://github.com/Kylmakalle/mixpanel-python-asyncio/archive/1.0.0.zip

Code

from mixpanel_asyncio import Mixpanel

mp = Mixpanel(YOUR_TOKEN)

# tracks an event with certain properties
await mp.track(DISTINCT_ID, 'button clicked', {'color' : 'blue', 'size': 'large'})

# sends an update to a user profile
await mp.people_set(DISTINCT_ID, {'$first_name' : 'Ilya', 'favorite pizza': 'margherita'})

@MrEarle
Copy link

MrEarle commented Dec 5, 2023

I believe this is an important improvement. Since requests is sync, it blocks the event loop while waiting for a response.

This can impact frameworks such as FastAPI (or other asyncio based http frameworks). Blocking the event loop would make it so that the worker might not be able to process a request.

@fersarr
Copy link

fersarr commented Jan 10, 2025

Can we have an official async library for mixpanel? This would be very helpful

@DimaDDM
Copy link

DimaDDM commented Jan 11, 2025

3 years and still not progress. Wow! This is an impossible task for such company? Synchronous library is like using dial-up..

@dacevedo12
Copy link

@DimaDDM you should see amazon, lol boto/botocore#458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants