rizinorg / rz-pipe

Access rizin via pipe from any programming language!
33 stars 11 forks source link

Python: Add timeout option to open() to kill time-consuming cmd() calls #47

Closed arieltorti closed 1 year ago

arieltorti commented 1 year ago

Proposed changes to fix https://github.com/rizinorg/rz-pipe/issues/46

Usage:

import rzpipe

pipe = rzpipe.open("/bin/ls", cmd_timeout=10)
pipe.cmd('aa')
pipe.quit()

When the timeout is triggered it will throw an exception:

TimeoutError: Timeout of 10 seconds reached on 'rzpipe.cmd: aa'

By default, it won't enable timeout to be backward compatible

wargio commented 1 year ago

Nice! it makes sense to have a timeout on the command, but is not clear the time unit. can you rename it as cmd_timeout_ms or whatever is the time unit?

dgutson commented 1 year ago

thanks @XVilka @wargio , how do we proceed from here so this becomes available with pip install? rizin is hanging badly in a situation and is harmful for us

wargio commented 1 year ago

can you also bump the version? so we can just upload a new version to pip

arieltorti commented 1 year ago

I bumped it to 0.5.0 since we added a feature, let me know if you want to change it