Best Way To Bound Function Execution Time

T

Tim Daneliuk

I am writing some paramiko-based ssh routines. One of them logs into
a remote server and then does a sudo command. The problem is that if
the user provides the incorrect sudo password, the call hangs the other
end is waiting for the correct password to be entered.

Is there some standard Pythonic way to bound how long a function
call can run, after which time it is forcefully terminated?

TIA,
 
P

Paul Rubin

Tim Daneliuk said:
Is there some standard Pythonic way to bound how long a function
call can run, after which time it is forcefully terminated?

Basically, run it in a separate process and use os.kill to kill it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top