-
Notifications
You must be signed in to change notification settings - Fork 41
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
shutdown() should close connections and release resources #256
Comments
Adding to the above, the exception is on controller devices, i.e., if |
We've been relying on Python's garbage collection to get the serial connections closed (effectively releasing resources). However, we have a shutdown method so we should be closing the connections on `shutdown`.
An argument against closing the connections on If so, then the recommendation is to destroy the object device right after calling shutdown and we don't have to change anything. If don't have to change anything there's less things for us to maintain (it gets a bit tricky when the device class itself does not hold the serial connection itself). Anyway, a proposed fix is on my branch |
How does this reflect on situations like a required restart of cockpit but trying to avoid restarting microscope devices as this might require rehoming etc? It is a massive win that you can often start cockpit and not be required to re-init most devices as this can be time consuming and destructive of existing position states or other continuity information. |
This makes no difference to cockpit because cockpit never calls We're already saying that after Having the connection closed when the device object is destructed works (I don't think that's an issue). The question here is whether we should make it happens when If we decide "yes" that On the other hand, having it done explicitly on |
In general I think easy and simple is the way to go, but I do worry that this may come back to bite us later. However, that said, hardware always has weird behaviors and having to explicitly work out how to fully shutdown and disconnect every device and then code it into the module seem like quite some work, whereas just deleting the objects seems easy. I think we should make a very explicit statement in the documentation about what we do on shutdown, both for clarity when questions come up and to help future writers of new device modules (probably us). |
When we call shutdown we should release all the resources associated with the device. At the moment, we send all the required commands so that the device is down but on the case of serial devices we do not close the serial connection (the exact device that's causing issues at the moment is a Thorlabs Filter wheel). We've just been relying on Python's garbage collection to close the connection but not only is that no predictable, it also requires the object to get destroyed. We should be releasing the resources as soon as
shutdown()
is called.The point is, this thing should work:
The text was updated successfully, but these errors were encountered: