Revert 906f2b9028 on testit.py accidental commit
This commit is contained in:
parent
036c1dfa6f
commit
84a3abd11d
11
testit.py
11
testit.py
@ -1,23 +1,22 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from func_timeout import func_timeout, set_timeout, FunctionTimedOut
|
from func_timeout import func_timeout, FunctionTimedOut
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@set_timeout(2.5)
|
|
||||||
def doit(howmany):
|
def doit(howmany):
|
||||||
time.sleep(3)
|
time.sleep(2)
|
||||||
return 17 + howmany
|
return 17 + howmany
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
print ( "Should get return value of 23:" )
|
print ( "Should get return value of 23:" )
|
||||||
# print ( "\tGot Return: %s\n" %(str(func_timeout(4, doit, args=(6,))),) )
|
print ( "\tGot Return: %s\n" %(str(func_timeout(4, doit, args=(6,))),) )
|
||||||
|
|
||||||
print ( "\nShould time out (exception):" )
|
print ( "\nShould time out (exception):" )
|
||||||
try:
|
try:
|
||||||
print ( "\tGot Return: %s\n", str(doit(16)) )
|
print ("\tGot Return: %s\n" %(str(func_timeout(1, doit, kwargs={'howmany' : 16})),))
|
||||||
# print ("\tGot Return: %s\n" %(str(func_timeout(4, doit, kwargs={'howmany' : 16})),))
|
|
||||||
except FunctionTimedOut as e:
|
except FunctionTimedOut as e:
|
||||||
sys.stderr.write('\tGot Exception: %s\n' %(str(e),))
|
sys.stderr.write('\tGot Exception: %s\n' %(str(e),))
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user