enesbcs / rpieasy

Easy MultiSensor device based on Raspberry PI
GNU General Public License v3.0
158 stars 33 forks source link

Compatibility with python 3.11 #274

Closed clumsy-stefan closed 1 year ago

clumsy-stefan commented 1 year ago

Since python 3.8 generator based coroutines are deprecated and have been removed in 3.11. After upgrading to the latest OS which includes python 3.11 as default RPIEasy is failing when started.

See also here: https://docs.python.org/3.10/library/asyncio-task.html#generator-based-coroutines

Unfortunately my python knowledge especially about coroutines is not good enough to propose needed changes!

enesbcs commented 1 year ago

This means replacing the @asyncio.coroutine decorator with async def keyword, and yield from with await.

In other words: i have to go through the integrated Perver webserver line by line and fix it. :D Excellent.

Although stable releases like Ubuntu LTS is not yet affected as it is using Python 3.10, this is now only a problem for beta-testers... :) But yes it will be a huge problem in a year when the next LTS arrives, and i guess a lot of Python applications will be affected.

clumsy-stefan commented 1 year ago

This means replacing the @asyncio.coroutine decorator with async def keyword, and yield from with await.

I tried that and replaced all yield from's and async def... but then I don't get any answer anymore by HTTP (even though the server seems to run)... So it seems to be a bit more than search and replace, sorry for that..

enesbcs commented 1 year ago

I tried that and replaced all yield from's and async def... but then I don't get any answer anymore by HTTP (even though the server seems to run)... So it seems to be a bit more than search and replace, sorry for that..

It seems a long term project :D

clumsy-stefan commented 1 year ago

thanks...

so in the mean time I need to find how I can downgrade to an older python version on my RPI... (I'm running ubuntu/lunar since 2 days ;)

enesbcs commented 1 year ago

I think its working now.. although minor artifacts may arise from the code... added at commit https://github.com/enesbcs/rpieasy/commit/b14193308604bad16edb7f5789e6e30ab628b363

clumsy-stefan commented 1 year ago

Cool!! Thank you very much!!

I jsut updated it and did a few quick tests... It seems to run fine!!

I'll report if I find any issues!!

Thanks again for the quick fixing!!

clumsy-stefan commented 1 year ago

Runs for over a month without issues (in fact, I get the feeling that the web interface is more stable)...

So IMHO this issue can be closed!