Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: maximum recursion depth exceeded in cmp when calling create_app #60

Closed
elyast opened this issue Aug 10, 2015 · 8 comments
Closed

Comments

@elyast
Copy link
Contributor

elyast commented Aug 10, 2015

I am trying to create new app using library:

My json is following

{
    "id": "spark-history",
    "cmd": "/mnt/lib/spark/sbin/run-history-server.sh hdfs://stanley/spark-events $PORT",
    "cpus": 0.5,
    "mem": 1024,
    "env": {"MARATHON": "http://as-ha-1:8773,http://as-ha-2:8773,http://as-master:8773"},
    "constraints": [["hostname", "UNIQUE"]],
    "healthChecks": [{"path": "/", "portIndex": 0, "protocol": "HTTP"}],
    "ports": [5999],
    "upgradeStrategy": {"minimumHealthCapacity": 1},
    "instances": 1
}

my code to create such app is following:

cli = marathon.MarathonClient(['sample_address'])
mApp = marathon.MarathonApp.from_json(app_attr)
app = cli.create_app('sample_name', mApp)

I am testing it against marathon 0.9.1, request worked in version 0.6.15 (tough parsing response failed)

however in version 0.7.1 I am getting following exception:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-20-c21615dd7f2c> in <module>()
----> 1 app = cli.create_app(app_name, mApp)

/usr/local/lib/python2.7/site-packages/marathon/client.pyc in create_app(self, app_id, app)
    109         """
    110         app.id = app_id
--> 111         data = app.to_json()
    112         response = self._do_request('POST', '/v2/apps', data=data)
    113         if response.status_code == 201:

/usr/local/lib/python2.7/site-packages/marathon/models/base.pyc in to_json(self, minimal)
     39         """
     40         if minimal:
---> 41             return json.dumps(self.json_repr(minimal=True), cls=MarathonMinimalJsonEncoder, sort_keys=True)
     42         else:
     43             return json.dumps(self.json_repr(), cls=MarathonJsonEncoder, sort_keys=True)

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.pyc in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, encoding, default, sort_keys, **kw)
    248         check_circular=check_circular, allow_nan=allow_nan, indent=indent,
    249         separators=separators, encoding=encoding, default=default,
--> 250         sort_keys=sort_keys, **kw).encode(obj)
    251 
    252 

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.pyc in encode(self, o)
    207         chunks = self.iterencode(o, _one_shot=True)
    208         if not isinstance(chunks, (list, tuple)):
--> 209             chunks = list(chunks)
    210         return ''.join(chunks)
    211 

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.pyc in _iterencode(o, _current_indent_level)
    432                 yield chunk
    433         elif isinstance(o, dict):
--> 434             for chunk in _iterencode_dict(o, _current_indent_level):
    435                 yield chunk
    436         else:

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.pyc in _iterencode_dict(dct, _current_indent_level)
    406                 else:
    407                     chunks = _iterencode(value, _current_indent_level)
--> 408                 for chunk in chunks:
    409                     yield chunk
    410         if newline_indent is not None:

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.pyc in _iterencode_list(lst, _current_indent_level)
    330                 else:
    331                     chunks = _iterencode(value, _current_indent_level)
--> 332                 for chunk in chunks:
    333                     yield chunk
    334         if newline_indent is not None:

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.pyc in _iterencode(o, _current_indent_level)
    440                     raise ValueError("Circular reference detected")
    441                 markers[markerid] = o
--> 442             o = _default(o)
    443             for chunk in _iterencode(o, _current_indent_level):
    444                 yield chunk

/usr/local/lib/python2.7/site-packages/marathon/util.pyc in default(self, obj)
     34     def default(self, obj):
     35         if hasattr(obj, 'json_repr'):
---> 36             return self.default(obj.json_repr(minimal=True))
     37 
     38         if isinstance(obj, datetime.datetime):

/usr/local/lib/python2.7/site-packages/marathon/util.pyc in default(self, obj)
     43                 return {k: self.default(v) for k,v in obj.items() if (v or v == False)}
     44             except AttributeError:
---> 45                 return [self.default(e) for e in obj if (e or e == False)]
     46 
     47         return obj

/usr/local/lib/python2.7/site-packages/marathon/util.pyc in default(self, obj)
     43                 return {k: self.default(v) for k,v in obj.items() if (v or v == False)}
     44             except AttributeError:
---> 45                 return [self.default(e) for e in obj if (e or e == False)]
     46 
     47         return obj

...

# here the infinite loop starts and finally (above few lines repeats)

...

/usr/local/lib/python2.7/site-packages/marathon/util.pyc in default(self, obj)
     43                 return {k: self.default(v) for k,v in obj.items() if (v or v == False)}
     44             except AttributeError:
---> 45                 return [self.default(e) for e in obj if (e or e == False)]
     46 
     47         return obj

/usr/local/lib/python2.7/site-packages/marathon/util.pyc in default(self, obj)
     39             return obj.isoformat()
     40 
---> 41         if isinstance(obj, collections.Iterable) and not isinstance(obj, str):
     42             try:
     43                 return {k: self.default(v) for k,v in obj.items() if (v or v == False)}

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.pyc in __instancecheck__(cls, instance)
    130         # Inline the cache checking when it's simple.
    131         subclass = getattr(instance, '__class__', None)
--> 132         if subclass is not None and subclass in cls._abc_cache:
    133             return True
    134         subtype = type(instance)

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_weakrefset.pyc in __contains__(self, item)
     73         except TypeError:
     74             return False
---> 75         return wr in self.data
     76 
     77     def __reduce__(self):

RuntimeError: maximum recursion depth exceeded in cmp

@elyast
Copy link
Contributor Author

elyast commented Aug 11, 2015

Hi, by the way I tested master branch, and it works there, (introducing is_stringy method probably helped)

Would you mind releasing master brach?

@solarkennedy
Copy link
Contributor

Does it really? Cause I have copy+pasted your example code and have a different error:
https://travis-ci.org/thefactory/marathon-python/builds/75198260

@elyast
Copy link
Contributor Author

elyast commented Aug 12, 2015

Surprisingly it does, however I am testing in the prod environment with marathon 0.9.1, are sure the integration tests are configured properly?

@solarkennedy
Copy link
Contributor

Heheh. Pretty sure? :)
But I'm calling the from_json method directly on the string which you provided, which you can't do (aparently) . Your app_attr var is probably a real python object, and not a string right?

This reminds me of this, which was fixed: #54

So if master is working for you, then all we need to do is make a more recent release for you to use? (see also #61)

@elyast
Copy link
Contributor Author

elyast commented Aug 12, 2015

so far so good :), I see I forgot to include crucial part of it, here is how object app_attr is being created

app_atrr = json.loads(some_string) 

so the app_attr is not a string

Releasing master would be nice, so far I am using my fork. Thanks

@solarkennedy
Copy link
Contributor

I don't have permission to make releases, but I've asked for a new release for #61

@solarkennedy
Copy link
Contributor

@elyast can you confirm if this is still an issue?

@elyast
Copy link
Contributor Author

elyast commented Jun 23, 2016

Lets close it for now, I don't have any issues with that

@elyast elyast closed this as completed Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants