gaogaotiantian / objprint

A library that can print Python objects in human readable format
Apache License 2.0
510 stars 43 forks source link

Feature: Add a time limit for `op` and `objprint` #96

Open WangGithubUser opened 1 year ago

WangGithubUser commented 1 year ago

Feature request

We can use op or objprint's option depth to control the time spend in printing.But, if we don't know the suitable depth, or even we don't know or can't know what the object is, a time limit can make the program to not stuck.

If you wish, I can bring you a implementation of this.

gaogaotiantian commented 1 year ago

It's true that objprint can in theory spend a long time iterating through the object, but that's not something we should deal with a timeout. print has a similar issue - it can be stuck printing an object, and the way to get out of it is just Ctrl+C. It's ultimiately in user's control and responsibility to make objprint work as they wish.

WangGithubUser commented 1 year ago

But a print seldom stuck, and if you run op with honor_existing=False, it will simply stuck. And, for

and the way to get out of it is just Ctrl+C

,if I need batch processing?Maybe I need to print the object that can finish in a set time.