Re: [PATCH python] Optimize callback lookup in event handlers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/03/2013 09:01 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> The event handler code currently invokes PyImport_ImportModule
> which is very heavyweight. This is not in fact required, since
> we know the libvirt module has already been imported. We can
> thus use PyImport_ImportModuleNoBlock and do away with the
> global variables caching the imported module reference.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  libvirt-override.c | 35 +++++++++++------------------------
>  1 file changed, 11 insertions(+), 24 deletions(-)
> 

> -    /* Bogus (char *) cast for RHEL-5 python API brokenness */
> -    libvirt_module = PyImport_ImportModule((char *)"libvirt");
> -    if (!libvirt_module) {
> -        DEBUG("%s Error importing libvirt module\n", __FUNCTION__);
> +getLibvirtDictObject(void) {
> +    PyObject *libvirt_mod;
> +    PyObject *libvirt_dict;
> +
> +    libvirt_mod = PyImport_ImportModuleNoBlock("libvirt");

Do we still need the bogus cast?  (I guess I should try building
libvirt-python on my RHEL-5 VM...)

>      if (!libvirt_dict) {
> -        DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__);
> +        DEBUG("%s Error finding libvirt dict\n",
> +	      __FUNCTION__);

Indentation looks off.  Oh - TAB damage.  Hmm - we really ought to
figure out how to reinstate some syntax checking.

It's probably not worth waiting for the RHEL 5 results (or, more likely,
it will be more than just this area that needs patching for building
libvirt-python on RHEL 5), so I'm okay with giving ACK and letting you
push as is.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]