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

CallbackError #85

Open
JintaoLee-Roger opened this issue Apr 2, 2022 · 4 comments
Open

CallbackError #85

JintaoLee-Roger opened this issue Apr 2, 2022 · 4 comments

Comments

@JintaoLee-Roger
Copy link

After installing by using the command "pip install tiptop", I ran the command "tiptop" and got the desired result. However, the result is just kept 1s, then I got the following errors:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│                                                                              │
│ /home/roger/miniconda3/lib/python3.8/site-packages/tiptop/_cpu.py:210 in     │
│ collect_data                                                                 │
│                                                                              │
│   207 │                                                                      │
│   208 │   def collect_data(self):                                            │
│   209 │   │   # CPU loads                                                    │
│ ❱ 210 │   │   self.cpu_total_stream.add_value(psutil.cpu_percent())          │
│   211 │   │   #                                                              │
│   212 │   │   load_per_thread = psutil.cpu_percent(percpu=True)              │
│   213 │   │   assert isinstance(load_per_thread, list)                       │
│                                                                              │
│ ╭───────── locals ─────────╮                                                 │
│ │ self = CPU(name='CPU#1') │                                                 │
│ ╰──────────────────────────╯                                                 │
│ /home/roger/miniconda3/lib/python3.8/site-packages/tiptop/braille_stream.py: │
│ 87 in add_value                                                              │
│                                                                              │
│    84 │   │                                                                  │
│    85 │   │   # update stream                                                │
│    86 │   │   for k, char in enumerate(chars):                               │
│ ❱  87 │   │   │   g[k] = g[k][1:] + char                                     │
│    88 │   │                                                                  │
│    89 │   │   self.values = self.values[1:] + [value]                        │
│    90 │   │   self._last_blocks = blocks                                     │
│                                                                              │
│ ╭──────────────────────────────── locals ─────────────────────────────────╮  │
│ │ blocks = [1, 0, 0, 0]                                                   │  │
│ │   char = ' '                                                            │  │
│ │  chars = [' ', ' ', ' ', '⣀']                                           │  │
│ │      g = []                                                             │  │
│ │      k = 0                                                              │  │
│ │   self = <tiptop.braille_stream.BrailleStream object at 0x7f9d3a4a1ca0> │  │
│ │  value = 3.3                                                            │  │
│ ╰─────────────────────────────────────────────────────────────────────────╯  │
╰──────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range

During handling of the above exception, another exception occurred:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│                                                                              │
│ /home/roger/miniconda3/lib/python3.8/site-packages/textual/message_pump.py:3 │
│ 27 in on_timer                                                               │
│                                                                              │
│   324 │   │   │   try:                                                       │
│   325 │   │   │   │   await invoke(event.callback)                           │
│   326 │   │   │   except Exception as error:                                 │
│ ❱ 327 │   │   │   │   raise CallbackError(                                   │
│   328 │   │   │   │   │   f"unable to run callback {event.callback!r}; {erro │
│   329 │   │   │   │   )                                                      │
│   330                                                                        │
│                                                                              │
│ ╭───────────── locals ──────────────╮                                        │
│ │ event = Timer('Timer#1', count=0) │                                        │
│ │  self = CPU(name='CPU#1')         │                                        │
│ ╰───────────────────────────────────╯                                        │
╰──────────────────────────────────────────────────────────────────────────────╯
CallbackError: unable to run callback <bound method CPU.collect_data of 
CPU(name='CPU#1')>; list index out of range
@JintaoLee-Roger
Copy link
Author

My OS information:
Ubuntu20.04,
python=3.8.5,
pip=20.2.4

Hope to get a reply. Thanks!

@nschloe
Copy link
Owner

nschloe commented Apr 2, 2022

What does

import psutil

print(psutil.cpu_percent())
print(psutil.cpu_percent(percpu=True))

give on your machine?

@JintaoLee-Roger
Copy link
Author

I got this:

>>> import psutil
>>> print(psutil.cpu_percent())
3.0
>>> print(psutil.cpu_percent(percpu=True))
[0.6, 0.1, 8.9, 3.1, 8.8, 2.5, 6.9, 5.8, 4.8, 0.9, 0.7, 0.9, 0.3, 2.0, 3.1, 0.2, 4.1, 3.2, 2.6, 2.2, 1.9, 2.2, 2.4, 2.3, 8.3, 6.5, 12.3, 2.5, 8.9, 0.4, 0.4, 0.1, 0.9, 0.5, 0.4, 6.7, 0.4, 0.0, 0.0, 0.0]

@nschloe
Copy link
Owner

nschloe commented Apr 3, 2022

Looks alright. Not sure where it could be going wrong then.

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