The bug
I use a datatable to display data. I have roughly 150 rows, each consiting of 5 fields.
I receive real time items every 100ms and update the datatable according. This is my update code:
def _create_or_update_row(self, key: str, data: ContentType) -> None:
if key in self.table.rows:
for field in fields(data):
self.table.update_cell(
key,
field.name,
_dump_field(field.name, getattr(data, field.name)),
update_width=True,
)
else:
self.table.add_row(
key,
*(_dump_field(field.name, getattr(data, field.name)) for field in fields(data)),
key=key,
)
This is triggered by a message:
@on(DataChanged)
def data_changed(self, message: DataChanged) -> None:
self._create_or_update_row(message.key, message.ct)
This results in a huge CPU spike, roughly to 60% and higher:
This is due to a lot of ioctl calls, if I see that correctly:
and this happens a lot!!!
I can try to set up a simple project that reproduces the problem, but maybe you can tell me, what I'm doing wrong here.
Maybe this could be fixed by cachine the TIOCGWINSZ result and wait for SIGWINCH or similar?
The bug
I use a datatable to display data. I have roughly 150 rows, each consiting of 5 fields.
I receive real time items every 100ms and update the datatable according. This is my update code:
This is triggered by a message:
This results in a huge CPU spike, roughly to 60% and higher:
This is due to a lot of ioctl calls, if I see that correctly:
and this happens a lot!!!
I can try to set up a simple project that reproduces the problem, but maybe you can tell me, what I'm doing wrong here.
Maybe this could be fixed by cachine the
TIOCGWINSZresult and wait forSIGWINCHor similar?