I just want a function to finish in a specific time period (suppose within 5 secs) and return some value. In case it doesn't finish in 5 secs it should return a fail status (lets say 1). If below example executed within 5 secs it should return hostname, else return empty string or something else
def processFile(logfile):
file = open(logfile, 'a+')
hostname = "karma"
file.write('%s,%d,\"%s\",%s,%s;\n' %('\"JOB_NEW\"',int(time.time()),hostname,no_of_cpu,user))
return (hostname)
processFile(logfile)