pcp
[Top] [All Lists]

Re: [pcp] Python pmda instances

To: Martins Innus <minnus@xxxxxxxxxxx>
Subject: Re: [pcp] Python pmda instances
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Sun, 15 Feb 2015 19:00:26 -0500 (EST)
Cc: PCP Mailing List <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <54DE51A0.7070905@xxxxxxxxxxx>
References: <54DE51A0.7070905@xxxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: s3EkKQ/r0rgIFexBEZajpO8qmZzNEw==
Thread-topic: Python pmda instances
Hi Martins,

----- Original Message -----
> [...]
>      LIBPCP_PMDA.pmdaCacheStore(indom, cpmda.PMDA_CACHE_ADD, key,
> byref(insts[key]))
> TypeError: byref() argument must be a ctypes instance, not 'dict'
> 
> I can work around this by just storing an index instead, but I don't
> know enough about python to know if there is a way to make that cast work.

We're using the python ctypes module extensively in our PMDA (and PMAPI)
library wrappers.  To store into the pmdaCache pointers, we need to use
something that is a subclass of a ctypes class, usually "Structure", so
that the reference counting and type checking is done correctly (IIRC).

See src/pmdas/dmcache and/or src/pmdas/gluster PMDAs for example PMDAs
that use python pmdaCache-tracked objects.

cheers.

--
Nathan

<Prev in Thread] Current Thread [Next in Thread>