Closed sajmons closed 1 year ago
This is likely the effect I described in the README.md
in section "Error when restarting indiserver". The INDI server starts the driver as a sub-process and when the server crashes the sub-process does not get terminated.
There can only be one indi_pylibcamera.py
driver running on the machine. I will implement something that kills an existing driver at startup. I just need to find out how to do this in Python (without killing itself). That will certainly not work when the older driver was started by a different user, but that is not a normal use-case.
That would be great! Indi web manager automatically restart driver when necessary. It would greatly improved UX and robustness if you can figure that out.
I implemented the killing of an old driver in branch https://github.com/scriptorron/indi_pylibcamera/tree/35-camera-resource-not-released-properly It worked in my tests. But I found another issue: when you disconnect a camera and connect it again the following error comes up:
RuntimeError: Camera __init__ sequence did not complete.
It is reproducible by clicking in the driver "Connect", "Disconnect" and "Connect". This can also happen when you kill a driver which had a camera connected, start a new driver and connect the camera in the new driver. After a while it works. It seems, the libcamera stack still has a resource locked until a timeout occurs or a processing finished. I will try to find a solution.
I fixed the reconnect issue in the mentioned branch. It was easier than expected. Next days I will do more tests before I merge it to the master branch.
That's really great to hear that you managed to solve that problem. It should really graatly improve stability and robustness of imaging. Thumbs up!
Today I also added code to close camera when getting killed by SIGINT or SIGTERM. I will merge to main branch. Maybe you can give ma feedback if it works in your environment. Thanks.
Wow! Latest version feels amazing! Changing different INDI clients feels great. There is no more issuse if user don't disconect properly. Driver just works! You did amazing job! Driver is now really robust!
Thank you for your kind words. You have a big part on it: you test it in an environment I do not have. Thank you for your help!
I'm really glad that I can help.
I'm having problem with indi_pylibcamera driver after it was not properly disconected. It looks like that some process is still using camera. I tried to kill indiserver, restart indi_web_manager. Nothing helps. Only reboot or kill process python3 solves the problem.
Here is output of libcamera-hello after indi_pylibcamera not disconected properly.
It looks like python3 process is still using camera after drver crashed.
After I kill that process manually everithing is working again. Ekos connect properly.
Is it possible to somehow automate this step? Maybe you could remember that python3 processid on driver startup and write it down to some file. On next startup you check that file and if it containt processid you kill it?