Skip to content

Thonny is unhappy with large arrays #41

@sfe-SparkFro

Description

@sfe-SparkFro

Run the following in Thonny:

from ulab import numpy as np
img = np.zeros((240, 320, 3), dtype=np.uint8)

Then try to do anything. For example, try running print("foo") in the shell. You can't.

I suspect the problem is that Thonny calls globals() to have all global variable names for tab completion and viewing variables, but ulab is printing too much for Thonny to handle. If I reboot the board after running the code above, I get the error message:

PROBLEM IN THONNY'S BACK-END: Exception while handling 'get_globals' (ConnectionError: EOF).
See Thonny's backend.log for more info.
You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.

while handling 'get_globals' implies to me that Thonny was parsing the contents of globals() and froze for some reason. If I run the same code with mpremote and then call globals(), it spends a few seconds printing the array, then the REPL continues working as fine. So that indicates to me it's a bug with Thonny.

However, ulab should also not be printing so much content. Will see if the solution to v923z/micropython-ulab#728 provides a workaround by just printing less.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions