<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>RE: [libvirt] [RFC] domain-events-python</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>One issue that I seem to be running into for both dom, and conn objects is the creation of a python object from the C vir{Connect,Domain}Ptr<BR>
<BR>
The issue is that when creating a python object, and passing "_obj" into the constructor - it will give a different python object each time, instead of searching for an existing object, and bumping the ref count.<BR>
<BR>
For example - each time the C callback would be called, we would create a new python object with the came "._o", rather than getting a new reference to a common one<BR>
<BR>
This is not an issue unless we want to store data in the python object independent from C object (like the python callback list)<BR>
<BR>
So...we could create a hash/dict object of virConnect objects...but when would you know to delete the last reference?<BR>
<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: Daniel Veillard [<A HREF="mailto:veillard@redhat.com">mailto:veillard@redhat.com</A>]<BR>
Sent: Wed 10/29/2008 2:50 AM<BR>
To: Daniel P. Berrange<BR>
Cc: Ben Guthro; libvir-list@redhat.com<BR>
Subject: Re: [libvirt] [RFC] domain-events-python<BR>
<BR>
On Tue, Oct 28, 2008 at 06:23:20PM +0000, Daniel P. Berrange wrote:<BR>
> On Tue, Oct 28, 2008 at 09:09:53AM -0400, Ben Guthro wrote:<BR>
> > Attached is a preliminary patch implementing the python bindings for<BR>
> > domain events, and the EventImpl code.<BR>
> ><BR>
> > This implements a python test app equivalent to the code in the C<BR>
> > event-test app. Contrary to what Daniel B originally suggested, I thought<BR>
> > that the EventImpl would be useful to expose for apps that are strictly<BR>
> > using python, and not integrating with glib, or another event loop. It<BR>
> > also makes the test case easier to debug.<BR>
><BR>
> That's a good idea - does make it easier to debug.<BR>
<BR>
  yes +1 definitely<BR>
<BR>
> > I have not marked this with [PATCH] in the subject, as I don't believe<BR>
> > it is quite complete.<BR>
> ><BR>
> > I am still having a few issues with the Refcounting in the C code, and<BR>
> > I think there is still some cleanup code I haven't quite handled quite<BR>
> > right.<BR>
> ><BR>
> > That said - I would welcome some comments/suggestions on this thus far,<BR>
> > to make sure I'm not going off in a direction contrary to where you<BR>
> > think I should be.<BR>
><BR>
> I think my main thought would be to try and domore of the event<BR>
> dispatch work in the python layer, rather than C layer. So rather<BR>
> than doing the de-multiplexing to all registered callbacks in<BR>
> libvirt_virConnectDomainEventCallback, have that C method call<BR>
> into a python  virConnectDomainEventCallback function, and have<BR>
> that de-multiplex the events out to all application callbacks.<BR>
> I think it'd probably make the code a little easier to follow,<BR>
> and might simplify the ref counting problems.<BR>
><BR>
> Likewise I think I'd also keep more of the 'DomainEventRegister' and<BR>
> 'Unregister' impl in the python layer. Perhaps keeping the list of<BR>
> callbacks as an attribute in the 'class virConnect', rather than the<BR>
> static global variable pyobj_domain_event_cbs.<BR>
<BR>
  Agreed too, since we don't care too much about performances in that<BR>
code it is really easier to implement and debug if most of the logic is<BR>
done in Python rather than C.<BR>
  The reference counting problem in callback based interfaces can be<BR>
nasty as I found out in libxml2, that too can be simplified greatly by<BR>
doing most of the work on the python side.<BR>
<BR>
  thanks !<BR>
<BR>
Daniel<BR>
<BR>
--<BR>
Daniel Veillard      | libxml Gnome XML XSLT toolkit  <A HREF="http://xmlsoft.org/">http://xmlsoft.org/</A><BR>
daniel@veillard.com  | Rpmfind RPM search engine <A HREF="http://rpmfind.net/">http://rpmfind.net/</A><BR>
<A HREF="http://veillard.com/">http://veillard.com/</A> | virtualization library  <A HREF="http://libvirt.org/">http://libvirt.org/</A><BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>