Hi,
I’m currently developing a mid-sized app with Python + PySide6.
Unfortunately every time I start / debug the work in progress, everything seems to work normally:
I click on a treeView item → the corresponding tableView (that lists the data in the selected class instance) updates.
Do that between 10 and 300 times and the app will suddenly crash without any errors.
If I enable faulthandler, it points to a pandas related line of code (most of the times):
Windows fatal exception: access violation
[...]
Current thread 0x00001768 (most recent call first):
Garbage-collecting
File "c:\...\.venv\Lib\site-packages\pandas\core\flags.py", line 55 in __init__
File "c:\...\.venv\Lib\site-packages\pandas\core\generic.py", line 279 in __init__
File "c:\...\.venv\Lib\site-packages\pandas\core\generic.py", line 352 in _from_mgr
File "c:\...\.venv\Lib\site-packages\pandas\core\frame.py", line 652 in _sliced_from_mgr
File "c:\...\.venv\Lib\site-packages\pandas\core\frame.py", line 656 in _constructor_sliced_from_mgr
File "c:\...\.venv\Lib\site-packages\pandas\core\frame.py", line 4392 in _box_col_values
File "c:\...\.venv\Lib\site-packages\pandas\core\frame.py", line 3804 in _ixs
File "c:\...\.venv\Lib\site-packages\pandas\core\frame.py", line 4002 in _get_value
File "c:\...\.venv\Lib\site-packages\pandas\core\indexing.py", line 2440 in __getitem__
File "c:\...\tools\mainwindow\models.py", line 146 in data
File "c:\...\main_app.py", line 168 in init_mainwindow
File "c:\...\start_app.py", line 11 in <module>
File "c:\...\.vscode\extensions\ms-python.python-2023.21.13101009\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124 in _run_code
line 146 in models.py:
value = self.tab_dat.iat[index.row(), index.column()]
tab_dat is a DataFrame with a few rows.
More context:
class TableModelDBMainPage(QtCore.QAbstractTableModel):
def __init__(self, tab_dat=pd.DataFrame(), parent=None):
super(TableModelDBMainPage, self).__init__()
self.tab_dat = tab_dat
self.parent = parent
self.colors = parent.colors
def data(self, index, role):
value = self.tab_dat.iat[index.row(), index.column()]
attribute = self.tab_dat.columns[index.column()]
if isinstance(value, datetime.datetime):
value = datetime.datetime.strftime(value, "%d.%m.%Y - %H:%M")
[...]
tab_dat holds the data for the tableView model.
It is updated each time when the treeView is clicked.
That works, as mentioned, like 10-300 times before it crashes.
However, it’s not always pandas related, one time it crashed when loading in a dictionary…
More Info:
- Python 3.11.4, Pandas 2.1.2, PySide6 6.6.0
- I tried memory_profiler → as far as I can tell there is no memory leak (by looking at the graph)
- no threading in app
- I tried pdb instead of the vscode python debugger → also crashes after some time
- I tried deleting the model data (DataFrame) each time before updating
- rebuilt .venv from scratch
- updated all dependecies
Does anyone have an idea or additional approaches?
Thank you.