param: Limit recursion in reprs to avoid stack overflow for circular references
System Info
- param 1.9.3
- pytest 5.3.1
- Windows 8.1
My Pain
I’m developing a component based on Param and Panel and would like to test it with pytest. During development my tests stopped working/ running but without errors. After some debugging I discovered it was due to a stackoverflow that pytest did not report. It just stopped.
I’ve developed a smaller code example below. I’ve also included the stack trace.
Stack Trace
$ python 'test_issue_multple_param_action.py'
Fatal Python error: Cannot recover from stack overflow.
Current thread 0x00001be8 (most recent call first):
File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 1535 in get_param_values
File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 2408 in __repr__
File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 2408 in <listcomp>
..........
File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 2408 in <listcomp>
File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 2408 in __repr__
...
(.venv)
Code
import param
class InputDataComponent(param.Parameterized):
update_data = param.Action()
download_data = param.Action()
def __init__(self, **params):
super().__init__(**params)
self.update_data = self._update_data
self.download_data = self._download_data
def _update_data(self, event):
raise NotImplementedError()
def _download_data(self, event):
raise NotImplementedError()
repr(InputDataComponent())
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (11 by maintainers)
We should try this https://twitter.com/raymondh/status/1276571193710047232?s=19
Just for info. I just experienced this again in another use case. I can live with it now that I know the cause and a workaround. But I think it could be annoying for a lot of other users.
@MarcSkovMadsen sorry, unrelated question! When I click to open a new issue on a holoviz repo (including param), I get the view below, and then the issue is created with labels like “triage” and “bug” (depending which option I pick):
Meanwhile, your issue is somehow without that stuff.
We’ve been trying to improve all this stuff across holoviz, having org-wide templates and so forth - but seems like we haven’t done something right somewhere…