jodal / pykka

🌀 Pykka makes it easier to build concurrent Python applications.
https://pykka.readthedocs.io
Apache License 2.0
1.21k stars 107 forks source link

Async Pykka Proof of Concept #218

Open x0ul opened 1 month ago

x0ul commented 1 month ago

I am working on an async Python project and wanted to use Pykka, so I decided to extend Pykka to work with async/await. Since this requires API changes, I made a new src/pykka/asyncio subdirectory and copied over specific files needing modifications (this is how redis does it, no idea if it's a good idea but it seemed to make things go smoothly).

There is also a new tests/asyncio subdirectory full of tests for this new code. 99%+ of the tests are the same, just modified for async. I removed one or two that were no longer relevant, and added one or two new ones.

Linters, type checkers, etc. should all be passing.

Still to do:

I'm interested to hear what you think about this :)

jodal commented 1 month ago

I've been considering to do something like this myself several times, but has never taken the step. I guess throwing backwards compatibility out and just see where it takes you is a valuable exercise.

I don't think I'd merge a copy of everything, but I'd be very much interested in having a look at what you've done and consider if we could go in this direction.

What do you think about moving everything from pykka.asyncio back to pykka? Then this PR would become a nice way to see what you've changed.

x0ul commented 1 month ago

Sorry for the delay in replying, I'm in the middle of moving house and will be away from the keyboard for the next few days. I'll get to this in a week, if that's alright.

What do you think about moving everything from pykka.asyncio back to pykka? Then this PR would become a nice way to see what you've changed.

Yes, I can do that, however it will definitely break API compatibility with original pykka because of the need to mark many functions as async.

Perhaps pykka-async as a separate project could be a reasonable way forward, any thoughts?

jodal commented 1 month ago

That's entirely alright!

I was just thinking that this would be a good first step just to easier review the differences. I agree that the changes probably are too large to easily integrate into Pykka, but there might be pieces that we could fit in to reduce the diff or extensions point we could create.

If it becomes a project of its own, I think the name should be more different, as pykka-async almost indicates an extension to Pykka, but there are no guarantees that the async fork would stay in sync with the sync version over time. Anyway, that's a discussion for later.