Yelp / python-gearman

Gearman API - Client, worker, and admin client interfaces
http://github.com/Yelp/python-gearman/
Other
242 stars 123 forks source link

Python 3.x Support #35

Open jsherer opened 11 years ago

jsherer commented 11 years ago

Python 3 was released in 2008 and has since become a very stable platform. Gearman needs to have a Python 3 supported library.

toudi commented 10 years ago

hi.

i would be willing to help in adding support for python 3.

any hints on how should this be achieved?

i looked at the code today. There were several exceptions which are catched this way:

except foo, bar

instead of

except foo as bar

unfortunetely the pypi page for gearman states that it has support for python 2.4, so i don't think that we can easily rewrite this.

another thing seems to be also in connection.py - there is array.array('c') which is no longer supported, and array.array('u') is concidered deprecated and will soon be removed.

i tried changing it to array.array('b'), but then the decoding procedure fails somewhere in the middle, i still haven't figured this out yet.

last but not least, the connection manager uses asyncore / select calls. Would it be possible to use asyncio from python 3.4 ? or would we want to continue supporting python 3.0 which lacks it?

overall, what would be the target refactoring - have multiple python modules and attach them in setup.py based on python version?

like..

if python_version >= 3.4: ( append asyncio support )

elif python _version <= 2.7: append current packages

best regards

svisser commented 10 years ago

I would be interested in this as well.

I think we should consider dropping support 2.4 and 2.5 given that 2.6+ is more common nowadays. The latest Python release is Python 3.4 and it's more feasible to have a 2.6, 2.7 and 3.x+ compatible codebase as opposed to also supporting 2.4 and 2.5 (which are about a decade old now).

svisser commented 10 years ago

I have made a pull request here to make all non-risky changes towards making the codebase suitable for Python 2.x and Python 3.x: https://github.com/Yelp/python-gearman/pull/63. The next step would be to ensure bytes and Unicode separation is done properly, both in the code and in the tests.

toudi commented 10 years ago

oh, i have just seen it. great work!

i think that i'd need to do a fork of your branch so that we could work there and eventually add support for python 3 ;)

svisser commented 10 years ago

Yes, feel free to fork and make pull requests. We can then add full 3.x support, rename the issue and hopefully merge it in.

mitaka commented 10 years ago

+1 for python3 support. I have tried paching some code but it still fails with encoding/decoding the binary data.

svisser commented 10 years ago

@mitaka yes, I'm aware. Haven't worked on it recently. The issue is also that there isn't full code coverage for all parts and in those parts it's currently breaking in Python 3.x.

msjaiswal commented 8 years ago

We recently translated this client to python3. Give it a shot. Everything except administrative tasks should be fine. https://github.com/msjaiswal/python3-gearman

jsherer commented 8 years ago

Thanks for the heads up @msjaiswal. Did you not implement administrative tasks? Or is there another reason why they wouldn't work?

msjaiswal commented 8 years ago

Did not implement them yet.