Update documentation and fix version number specified in module

This commit is contained in:
Tim Savannah 2016-03-21 11:24:17 -04:00
parent 2bb4b52640
commit 675d68254d
8 changed files with 70 additions and 7 deletions

View File

@ -1,3 +1,6 @@
* 3.0.1 - Mar 21 2016
- Update documentation
* 3.0.0 - Mar 18 2016
- Change implementation to not leave lingering threads after a timeout occurs
- Split module into several parts

View File

@ -49,6 +49,14 @@ So, for esxample, if you have a function "doit('arg1', 'arg2')" that you want to
# Handle any exceptions that doit might raise here
How it works
------------
func\_timeout will run the specified function in a thread with the specified arguments until it returns, raises an exception, or the timeout is exceeded.
If there is a return or an exception raised, it will be returned/raised as normal.
If the timeout has exceeded, the "FunctionTimedOut" exception will be raised in the context of the function being called, as well as from the context of "func\_timeout". You should have your function catch the "FunctionTimedOut" exception and exit cleanly if possible. Every 2 seconds until your function is terminated, it will continue to raise FunctionTimedOut. The terminating of the timed-out function happens in the context of the thread and will not block main execution.
Support
-------

View File

@ -66,6 +66,13 @@ So, for esxample, if you have a function "doit('arg1', 'arg2')" that you want to
# Handle any exceptions that doit might raise here
How it works
------------
func_timeout will run the specified function in a thread with the specified arguments until it returns, raises an exception, or the timeout is exceeded.
If there is a return or an exception raised, it will be returned/raised as normal.
If the timeout has exceeded, the "FunctionTimedOut" exception will be raised in the context of the function being called, as well as from the context of "func_timeout". You should have your function catch the "FunctionTimedOut" exception and exit cleanly if possible. Every 2 seconds until your function is terminated, it will continue to raise FunctionTimedOut. The terminating of the timed-out function happens in the context of the thread and will not block main execution.
Support

View File

@ -9,7 +9,10 @@
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="func_timeout.html"><font color="#ffffff">func_timeout</font></a>.dafunc</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href="func_timeout.html">index</a></font></td></tr></table>
<p></p>
<p><tt>Copyright&nbsp;(c)&nbsp;2016&nbsp;Tim&nbsp;Savannah&nbsp;All&nbsp;Rights&nbsp;Reserved.<br>
&nbsp;<br>
Licensed&nbsp;under&nbsp;the&nbsp;Lesser&nbsp;GNU&nbsp;Public&nbsp;License&nbsp;Version&nbsp;3,&nbsp;LGPLv3.&nbsp;You&nbsp;should&nbsp;have&nbsp;recieved&nbsp;a&nbsp;copy&nbsp;of&nbsp;this&nbsp;with&nbsp;the&nbsp;source&nbsp;distribution&nbsp;as<br>
LICENSE,&nbsp;otherwise&nbsp;it&nbsp;is&nbsp;available&nbsp;at&nbsp;https://github.com/kata198/func_timeout/LICENSE</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
@ -37,6 +40,20 @@ Raises&nbsp;any&nbsp;exceptions&nbsp;#func#&nbsp;would&nbsp;raise,&nbsp;returns&
&nbsp;<br>
@raises&nbsp;-&nbsp;FunctionTimedOut&nbsp;if&nbsp;#timeout#&nbsp;is&nbsp;exceeded,&nbsp;otherwise&nbsp;anything&nbsp;#func#&nbsp;could&nbsp;raise&nbsp;will&nbsp;be&nbsp;raised<br>
&nbsp;<br>
If&nbsp;the&nbsp;timeout&nbsp;is&nbsp;exceeded,&nbsp;FunctionTimedOut&nbsp;will&nbsp;be&nbsp;raised&nbsp;within&nbsp;the&nbsp;context&nbsp;of&nbsp;the&nbsp;called&nbsp;function&nbsp;every&nbsp;two&nbsp;seconds&nbsp;until&nbsp;it&nbsp;terminates,<br>
but&nbsp;will&nbsp;not&nbsp;block&nbsp;the&nbsp;calling&nbsp;thread&nbsp;(a&nbsp;new&nbsp;thread&nbsp;will&nbsp;be&nbsp;created&nbsp;to&nbsp;perform&nbsp;the&nbsp;join).&nbsp;If&nbsp;possible,&nbsp;you&nbsp;should&nbsp;try/except&nbsp;FunctionTimedOut<br>
to&nbsp;return&nbsp;cleanly,&nbsp;but&nbsp;in&nbsp;most&nbsp;cases&nbsp;it&nbsp;will&nbsp;'just&nbsp;work'.<br>
&nbsp;<br>
Be&nbsp;careful&nbsp;of&nbsp;code&nbsp;like:<br>
def&nbsp;myfunc():<br>
&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;True:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dosomething()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;Exception:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br>
&nbsp;<br>
because&nbsp;it&nbsp;will&nbsp;never&nbsp;terminate.<br>
&nbsp;<br>
@return&nbsp;-&nbsp;The&nbsp;return&nbsp;value&nbsp;that&nbsp;#func#&nbsp;gives</tt></dd></dl>
</td></tr></table>
</body></html>

View File

@ -6,7 +6,7 @@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>func_timeout</strong></big></big> (version 2.0.0)</font></td
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>func_timeout</strong></big></big> (version 3.0.1)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href="func_timeout.html">index</a></font></td></tr></table>
<p><tt>Copyright&nbsp;(c)&nbsp;2016&nbsp;Tim&nbsp;Savannah&nbsp;All&nbsp;Rights&nbsp;Reserved.<br>
@ -45,7 +45,7 @@ LICENSE,&nbsp;otherwise&nbsp;it&nbsp;is&nbsp;available&nbsp;at&nbsp;https://gith
<font color="#000000" face="helvetica, arial"><a name="FunctionTimedOut">class <strong>FunctionTimedOut</strong></a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Common&nbsp;base&nbsp;class&nbsp;for&nbsp;all&nbsp;exceptions<br>&nbsp;</tt></td></tr>
<td colspan=2><tt><a href="#FunctionTimedOut">FunctionTimedOut</a>&nbsp;-&nbsp;Exception&nbsp;raised&nbsp;when&nbsp;a&nbsp;function&nbsp;times&nbsp;out<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="func_timeout.exceptions.html#FunctionTimedOut">FunctionTimedOut</a></dd>
@ -114,6 +114,20 @@ Raises&nbsp;any&nbsp;exceptions&nbsp;#func#&nbsp;would&nbsp;raise,&nbsp;returns&
&nbsp;<br>
@raises&nbsp;-&nbsp;<a href="#FunctionTimedOut">FunctionTimedOut</a>&nbsp;if&nbsp;#timeout#&nbsp;is&nbsp;exceeded,&nbsp;otherwise&nbsp;anything&nbsp;#func#&nbsp;could&nbsp;raise&nbsp;will&nbsp;be&nbsp;raised<br>
&nbsp;<br>
If&nbsp;the&nbsp;timeout&nbsp;is&nbsp;exceeded,&nbsp;<a href="#FunctionTimedOut">FunctionTimedOut</a>&nbsp;will&nbsp;be&nbsp;raised&nbsp;within&nbsp;the&nbsp;context&nbsp;of&nbsp;the&nbsp;called&nbsp;function&nbsp;every&nbsp;two&nbsp;seconds&nbsp;until&nbsp;it&nbsp;terminates,<br>
but&nbsp;will&nbsp;not&nbsp;block&nbsp;the&nbsp;calling&nbsp;thread&nbsp;(a&nbsp;new&nbsp;thread&nbsp;will&nbsp;be&nbsp;created&nbsp;to&nbsp;perform&nbsp;the&nbsp;join).&nbsp;If&nbsp;possible,&nbsp;you&nbsp;should&nbsp;try/except&nbsp;<a href="#FunctionTimedOut">FunctionTimedOut</a><br>
to&nbsp;return&nbsp;cleanly,&nbsp;but&nbsp;in&nbsp;most&nbsp;cases&nbsp;it&nbsp;will&nbsp;'just&nbsp;work'.<br>
&nbsp;<br>
Be&nbsp;careful&nbsp;of&nbsp;code&nbsp;like:<br>
def&nbsp;myfunc():<br>
&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;True:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dosomething()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;Exception:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br>
&nbsp;<br>
because&nbsp;it&nbsp;will&nbsp;never&nbsp;terminate.<br>
&nbsp;<br>
@return&nbsp;-&nbsp;The&nbsp;return&nbsp;value&nbsp;that&nbsp;#func#&nbsp;gives</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
@ -123,5 +137,5 @@ Raises&nbsp;any&nbsp;exceptions&nbsp;#func#&nbsp;would&nbsp;raise,&nbsp;returns&
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ('func_timeout', 'FunctionTimedOut')<br>
<strong>__version_tuple__</strong> = (2, 0, 0)</td></tr></table>
<strong>__version_tuple__</strong> = (3, 0, 1)</td></tr></table>
</body></html>

View File

@ -6,8 +6,8 @@
'''
__version__ = '2.0.0'
__version_tuple__ = (2, 0, 0)
__version__ = '3.0.1'
__version_tuple__ = (3, 0, 1)
__all__ = ('func_timeout', 'FunctionTimedOut')

View File

@ -23,6 +23,20 @@ def func_timeout(timeout, func, args=(), kwargs=None):
@raises - FunctionTimedOut if #timeout# is exceeded, otherwise anything #func# could raise will be raised
If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates,
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except FunctionTimedOut
to return cleanly, but in most cases it will 'just work'.
Be careful of code like:
def myfunc():
while True:
try:
dosomething()
except Exception:
continue
because it will never terminate.
@return - The return value that #func# gives
'''

View File

@ -30,7 +30,7 @@ if __name__ == '__main__':
log_description = summary
setup(name='func_timeout',
version='3.0.0',
version='3.0.1',
packages=['func_timeout'],
author='Tim Savannah',
author_email='kata198@gmail.com',