我正在尝试在一个类上设置一个属性:
class HandleOngoingStream:
def __init__(self):
self.live_data = None
@property
def live_data(self):
return self.live_data
@live_data.setter
def live_data(self, value):
url = "some url"
req = requests.get(url)
my_data = req.json()
self._live_data = my_data
if __name__ == '__main__':
data = HandleOngoingStream()
print(data.live_data)
我正在Django项目中运行此类,并使用PyCharm社区版本(不确定是否是造成这种情况的原因)
尝试调试此代码(使用PyCharm的调试器)时,出现以下错误:
Fatal Python error: Cannot recover from stack overflow.
Python runtime state: initialized
Thread 0x00007fa990be4700 (most recent call first):
File "/usr/lib/python3.8/threading.py", line 306 in wait
File "/usr/lib/python3.8/threading.py", line 558 in wait
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/pydevd.py", line 144 in _on_run
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 216 in run
File "/usr/lib/python3.8/threading.py", line 932 in _bootstrap_inner
File "/usr/lib/python3.8/threading.py", line 890 in _bootstrap
Thread 0x00007fa9913e5700 (most recent call first):
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 290 in _on_run
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 216 in run
File "/usr/lib/python3.8/threading.py", line 932 in _bootstrap_inner
File "/usr/lib/python3.8/threading.py", line 890 in _bootstrap
Thread 0x00007fa991be6700 (most recent call first):
File "/usr/lib/python3.8/threading.py", line 306 in wait
File "/usr/lib/python3.8/queue.py", line 179 in get
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 365 in _on_run
File "/snap/pycharm-community/211/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 216 in run
File "/usr/lib/python3.8/threading.py", line 932 in _bootstrap_inner
File "/usr/lib/python3.8/threading.py", line 890 in _bootstrap
Current thread 0x00007fa993dc5740 (most recent call first):
File "/PATH/TO/My/file.py", line 13 in live_data
# Bunch of this same lines
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)