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

[HTCondor-users] list(ExprTree) infinite loop



Condor 8.2.4 under ubuntu

Minor bug report: the python API can be made to hang if you call list() on certain forms of ExprTree. Reproducer:

>>> import classad
>>> classad.ExprTree('{ "foo" }')
{ "foo" }
>>> list(classad.ExprTree('{ "foo" }'))
['foo']
>>> classad.ExprTree('2+2')
2 + 2
>>> list(classad.ExprTree('2+2'))
[ HANGS HERE, EVENTUALLY CRASHES OOM ]

Or:

for i in classad.ExprTree('2+2'):
    print i
[ INFINITE LOOP, EVENTUALLY CRASHES OOM ]


Reason I'm doing this: I want to parse the node.status file, which is in new ClassAd format, and convert it to JSON.
http://research.cs.wisc.edu/htcondor/manual/current/2_10DAGMan_Applications.html#sec:DAG-node-status

The following code does more or less what I want:

ad = classad.parse(f)
jad = dict(ad)

except the DagFiles entry is an ExprTree. It can be forced to a str(), but that loses the structure of the value. Using list() here does what I want, but I was surprised to see it break for other ExprTree values.

It seems maybe classad.ExprTree.eval() is the way to go.

Regards,

Brian.