Jeremy Markle
2020-Aug-24 09:38 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
I was simply following the examples in the python-libvirt repo. If those methods raise exceptions I'll definitely change to try/catch. Thank you. The maintainer of the repo should update the examples and documentation if exceptions are raised by those. On Mon, Aug 24, 2020, 05:31 Daniel P. Berrangé <berrange@redhat.com> wrote:> On Sat, Aug 22, 2020 at 10:32:09AM -0400, Jeremy Markle wrote: > > I'm using the python-libvirt library and finding that I cannot get > > .destroy() or .shutdown() to work. > > > > > https://github.com/simora/docker-libvirt-flask/blob/cba6041b47bdf4ccb3b9506a0379cf8c788a9a57/root/app/mqtt.py#L96 > > Your code has alot of "< 0" checks. This is the C API behaviour to return > -1 > on error. In python we raise exceptions on error. so you try try/except to > catch them > > Daniel > >
Michal Privoznik
2020-Aug-24 10:08 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
On 8/24/20 11:38 AM, Jeremy Markle wrote:> I was simply following the examples in the python-libvirt repo. If those > methods raise exceptions I'll definitely change to try/catch. Thank you. > The maintainer of the repo should update the examples and documentation > if exceptions are raised by those. >Can you be more specific please? A quick git grep shows only a few cases which don't compare APIs rather than some integer variables: libvirt-python.git $ git grep -C 3 -e '< 0' --or -e '== 0' -- examples/ And those try/catch statements - in our basic examples we don't do any rollback and simply just let python abort. Michal
Jeremy Markle
2020-Aug-24 15:08 UTC
Re: python-libvirt domain.destroy() doesn't appear to be working for me
I apologize... the bits I saw the "< 0" testing were in the following link. The examples in the repo don't have either try/catch or the int testing such as in the second link. https://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains-Lifecycle_Control.html#libvirt_application_development_guide_using_python-Guest_Domains-Lifecycle-Provisioning_and_Starting https://gitlab.com/libvirt/libvirt-python/-/blob/d8d55b17e227f0ce829e709966f580861186f8ab/examples/domsave.py#L29 On Mon, Aug 24, 2020 at 6:09 AM Michal Privoznik <mprivozn@redhat.com> wrote:> On 8/24/20 11:38 AM, Jeremy Markle wrote: > > I was simply following the examples in the python-libvirt repo. If those > > methods raise exceptions I'll definitely change to try/catch. Thank you. > > The maintainer of the repo should update the examples and documentation > > if exceptions are raised by those. > > > > Can you be more specific please? A quick git grep shows only a few cases > which don't compare APIs rather than some integer variables: > > libvirt-python.git $ git grep -C 3 -e '< 0' --or -e '== 0' -- examples/ > > And those try/catch statements - in our basic examples we don't do any > rollback and simply just let python abort. > > Michal > >
Maybe Matching Threads
- Re: python-libvirt domain.destroy() doesn't appear to be working for me
- Re: python-libvirt domain.destroy() doesn't appear to be working for me
- python-libvirt domain.destroy() doesn't appear to be working for me
- Re: changeBegin() on python API
- Re: Libvirt: dynamic ownership did not work