pcp
[Top] [All Lists]

Re: [pcp] pmrep: handle multiple instances with pmi

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] pmrep: handle multiple instances with pmi
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Wed, 16 Dec 2015 12:48:21 +0200
Cc: pcp developers <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <864698968.41625184.1450214053630.JavaMail.zimbra@xxxxxxxxxx>
Organization: Red Hat
References: <56701F95.2000303@xxxxxxxxxx> <864698968.41625184.1450214053630.JavaMail.zimbra@xxxxxxxxxx>
Reply-to: myllynen@xxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
Hi,

On 2015-12-15 23:14, Nathan Scott wrote:
>> I don't see PMI_ERR_DUPINSTNAME being available on the Python side
>> (like it is on the Perl side) so use the hard coded number for now
>> and switch to PMI_ERR_DUPINSTNAME once there.
> 
> $ grep PMI_ERR_DUPINSTNAME src/python/*c
> src/python/pmi.c:    pmi_edict_add(dict, edict, "PMI_ERR_DUPINSTNAME", 
> PMI_ERR_DUPINSTNAME);
> 
> Looks like it is there already?

right, obviously it's under pmi not pmapi...

---
 src/pmrep/pmrep.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index fe33e5c..61a52d1 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -63,6 +63,7 @@ import re
 from pcp import pmapi, pmi
 from cpmapi import PM_CONTEXT_ARCHIVE, PM_CONTEXT_HOST, PM_CONTEXT_LOCAL, 
PM_MODE_FORW, PM_MODE_INTERP, PM_ERR_TYPE, PM_ERR_EOL, PM_ERR_NAME, PM_IN_NULL, 
PM_SEM_COUNTER, PM_TIME_MSEC, PM_TIME_SEC, PM_XTB_SET
 from cpmapi import PM_TYPE_32, PM_TYPE_U32, PM_TYPE_64, PM_TYPE_U64, 
PM_TYPE_FLOAT, PM_TYPE_DOUBLE, PM_TYPE_STRING
+from cpmi import PMI_ERR_DUPINSTNAME
 
 if sys.version_info[0] >= 3:
     long = int
@@ -1152,8 +1153,12 @@ class PMReporter(object):
                                       self.descs[i].contents.sem,
                                       self.descs[i].contents.units)
                 ins = 0 if self.insts[i][0][0] == PM_IN_NULL else 
len(self.insts[i][0])
-                for j in range(ins):
-                    self.log.pmiAddInstance(self.descs[i].contents.indom, 
self.insts[i][1][j], self.insts[i][0][j])
+                try:
+                    for j in range(ins):
+                        self.log.pmiAddInstance(self.descs[i].contents.indom, 
self.insts[i][1][j], self.insts[i][0][j])
+                except pmi.pmiErr as error:
+                    if error.args[0] == PMI_ERR_DUPINSTNAME:
+                        continue
 
         # Add current values
         data = 0

Thanks,

-- 
Marko Myllynen

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