Update pydoc
This commit is contained in:
parent
63454c7178
commit
d10476b734
@ -1,296 +1,305 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module func_timeout.StoppableThread</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
<html ><head ><title >Python: module func_timeout.StoppableThread</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head><body bgcolor="#f0f0f8" >
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="func_timeout.html"><font color="#ffffff">func_timeout</font></a>.StoppableThread</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>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="heading" >
|
||||
<tr bgcolor="#7799ee" >
|
||||
<td valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" > <br /><big ><big ><strong ><a href="func_timeout.html" ><font color="#ffffff" >func_timeout</font></a>.StoppableThread</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 ><tt >Copyright (c) 2016, 2017 Tim Savannah All Rights Reserved.<br />
|
||||
<br />
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br />
|
||||
LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE</tt></p>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#aa55cc" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="ctypes.html">ctypes</a><br>
|
||||
</td><td width="25%" valign=top><a href="threading.html">threading</a><br>
|
||||
</td><td width="25%" valign=top><a href="time.html">time</a><br>
|
||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
<tr ><td bgcolor="#aa55cc" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><table width="100%" summary="list" ><tr ><td width="25%" valign="top" ><a href="ctypes.html" >ctypes</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="os.html" >os</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="threading.html" >threading</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="time.html" >time</a><br />
|
||||
</td></tr></table></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ee77aa" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="threading.html#Thread">threading.Thread</a>(<a href="builtins.html#object">builtins.object</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="func_timeout.StoppableThread.html#JoinThread">JoinThread</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="func_timeout.StoppableThread.html#StoppableThread">StoppableThread</a>
|
||||
<tr ><td bgcolor="#ee77aa" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="threading.html#Thread" >threading.Thread</a>(<a href="builtins.html#object" >builtins.object</a>)
|
||||
</font></dt><dd >
|
||||
<dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="func_timeout.StoppableThread.html#JoinThread" >JoinThread</a>
|
||||
</font></dt><dt ><font face="helvetica, arial" ><a href="func_timeout.StoppableThread.html#StoppableThread" >StoppableThread</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="JoinThread">class <strong>JoinThread</strong></a>(<a href="threading.html#Thread">threading.Thread</a>)</font></td></tr>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ffc8d8" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#000000" face="helvetica, arial" ><a name="JoinThread" >class <strong >JoinThread</strong></a>(<a href="threading.html#Thread" >threading.Thread</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt><a href="#JoinThread">JoinThread</a> - The workhouse that stops the <a href="#StoppableThread">StoppableThread</a><br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="func_timeout.StoppableThread.html#JoinThread">JoinThread</a></dd>
|
||||
<dd><a href="threading.html#Thread">threading.Thread</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
<tr bgcolor="#ffc8d8" ><td rowspan="2" ><tt > </tt></td>
|
||||
<td colspan="2" ><tt ><a href="#JoinThread" >JoinThread</a> - The workhouse that stops the <a href="#StoppableThread" >StoppableThread</a><br /> </tt></td></tr>
|
||||
<tr ><td > </td>
|
||||
<td width="100%" ><dl ><dt >Method resolution order:</dt>
|
||||
<dd ><a href="func_timeout.StoppableThread.html#JoinThread" >JoinThread</a></dd>
|
||||
<dd ><a href="threading.html#Thread" >threading.Thread</a></dd>
|
||||
<dd ><a href="builtins.html#object" >builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods defined here:<br>
|
||||
<dl><dt><a name="JoinThread-__init__"><strong>__init__</strong></a>(self, otherThread, exception)</dt><dd><tt>This constructor should always be called with keyword arguments. Arguments are:<br>
|
||||
<br>
|
||||
*group* should be None; reserved for future extension when a ThreadGroup<br>
|
||||
class is implemented.<br>
|
||||
<br>
|
||||
*target* is the callable object to be invoked by the <a href="#JoinThread-run">run</a>()<br>
|
||||
method. Defaults to None, meaning nothing is called.<br>
|
||||
<br>
|
||||
*name* is the thread name. By default, a unique name is constructed of<br>
|
||||
the form "<a href="threading.html#Thread">Thread</a>-N" where N is a small decimal number.<br>
|
||||
<br>
|
||||
*args* is the argument tuple for the target invocation. Defaults to ().<br>
|
||||
<br>
|
||||
*kwargs* is a dictionary of keyword arguments for the target<br>
|
||||
invocation. Defaults to {}.<br>
|
||||
<br>
|
||||
If a subclass overrides the constructor, it must make sure to invoke<br>
|
||||
the base class constructor (<a href="threading.html#Thread">Thread</a>.<a href="#JoinThread-__init__">__init__</a>()) before doing anything<br>
|
||||
<hr />
|
||||
Methods defined here:<br />
|
||||
<dl ><dt ><a name="JoinThread-__init__" ><strong >__init__</strong></a>(self, otherThread, exception)</dt><dd ><tt >This constructor should always be called with keyword arguments. Arguments are:<br />
|
||||
<br />
|
||||
*group* should be None; reserved for future extension when a ThreadGroup<br />
|
||||
class is implemented.<br />
|
||||
<br />
|
||||
*target* is the callable object to be invoked by the <a href="#JoinThread-run" >run</a>()<br />
|
||||
method. Defaults to None, meaning nothing is called.<br />
|
||||
<br />
|
||||
*name* is the thread name. By default, a unique name is constructed of<br />
|
||||
the form "<a href="threading.html#Thread" >Thread</a>-N" where N is a small decimal number.<br />
|
||||
<br />
|
||||
*args* is the argument tuple for the target invocation. Defaults to ().<br />
|
||||
<br />
|
||||
*kwargs* is a dictionary of keyword arguments for the target<br />
|
||||
invocation. Defaults to {}.<br />
|
||||
<br />
|
||||
If a subclass overrides the constructor, it must make sure to invoke<br />
|
||||
the base class constructor (<a href="threading.html#Thread" >Thread</a>.<a href="#JoinThread-__init__" >__init__</a>()) before doing anything<br />
|
||||
else to the thread.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-run"><strong>run</strong></a>(self)</dt><dd><tt>Method representing the thread's activity.<br>
|
||||
<br>
|
||||
You may override this method in a subclass. The standard <a href="#JoinThread-run">run</a>() method<br>
|
||||
invokes the callable object passed to the object's constructor as the<br>
|
||||
target argument, if any, with sequential and keyword arguments taken<br>
|
||||
<dl ><dt ><a name="JoinThread-run" ><strong >run</strong></a>(self)</dt><dd ><tt >Method representing the thread's activity.<br />
|
||||
<br />
|
||||
You may override this method in a subclass. The standard <a href="#JoinThread-run" >run</a>() method<br />
|
||||
invokes the callable object passed to the object's constructor as the<br />
|
||||
target argument, if any, with sequential and keyword arguments taken<br />
|
||||
from the args and kwargs arguments, respectively.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
||||
<dl><dt><a name="JoinThread-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
<hr />
|
||||
Methods inherited from <a href="threading.html#Thread" >threading.Thread</a>:<br />
|
||||
<dl ><dt ><a name="JoinThread-__repr__" ><strong >__repr__</strong></a>(self)</dt><dd ><tt >Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-getName"><strong>getName</strong></a>(self)</dt></dl>
|
||||
<dl ><dt ><a name="JoinThread-getName" ><strong >getName</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-isAlive"><strong>isAlive</strong></a> = is_alive(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
||||
<br>
|
||||
This method returns True just before the <a href="#JoinThread-run">run</a>() method starts until just<br>
|
||||
after the <a href="#JoinThread-run">run</a>() method terminates. The module function enumerate()<br>
|
||||
<dl ><dt ><a name="JoinThread-isAlive" ><strong >isAlive</strong></a> = is_alive(self)</dt><dd ><tt >Return whether the thread is alive.<br />
|
||||
<br />
|
||||
This method returns True just before the <a href="#JoinThread-run" >run</a>() method starts until just<br />
|
||||
after the <a href="#JoinThread-run" >run</a>() method terminates. The module function enumerate()<br />
|
||||
returns a list of all alive threads.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-isDaemon"><strong>isDaemon</strong></a>(self)</dt></dl>
|
||||
<dl ><dt ><a name="JoinThread-isDaemon" ><strong >isDaemon</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-is_alive"><strong>is_alive</strong></a>(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
||||
<br>
|
||||
This method returns True just before the <a href="#JoinThread-run">run</a>() method starts until just<br>
|
||||
after the <a href="#JoinThread-run">run</a>() method terminates. The module function enumerate()<br>
|
||||
<dl ><dt ><a name="JoinThread-is_alive" ><strong >is_alive</strong></a>(self)</dt><dd ><tt >Return whether the thread is alive.<br />
|
||||
<br />
|
||||
This method returns True just before the <a href="#JoinThread-run" >run</a>() method starts until just<br />
|
||||
after the <a href="#JoinThread-run" >run</a>() method terminates. The module function enumerate()<br />
|
||||
returns a list of all alive threads.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-join"><strong>join</strong></a>(self, timeout=None)</dt><dd><tt>Wait until the thread terminates.<br>
|
||||
<br>
|
||||
This blocks the calling thread until the thread whose <a href="#JoinThread-join">join</a>() method is<br>
|
||||
called terminates -- either normally or through an unhandled exception<br>
|
||||
or until the optional timeout occurs.<br>
|
||||
<br>
|
||||
When the timeout argument is present and not None, it should be a<br>
|
||||
floating point number specifying a timeout for the operation in seconds<br>
|
||||
(or fractions thereof). As <a href="#JoinThread-join">join</a>() always returns None, you must call<br>
|
||||
<a href="#JoinThread-isAlive">isAlive</a>() after <a href="#JoinThread-join">join</a>() to decide whether a timeout happened -- if the<br>
|
||||
thread is still alive, the <a href="#JoinThread-join">join</a>() call timed out.<br>
|
||||
<br>
|
||||
When the timeout argument is not present or None, the operation will<br>
|
||||
block until the thread terminates.<br>
|
||||
<br>
|
||||
A thread can be <a href="#JoinThread-join">join</a>()ed many times.<br>
|
||||
<br>
|
||||
<a href="#JoinThread-join">join</a>() raises a RuntimeError if an attempt is made to join the current<br>
|
||||
thread as that would cause a deadlock. It is also an error to <a href="#JoinThread-join">join</a>() a<br>
|
||||
thread before it has been started and attempts to do so raises the same<br>
|
||||
<dl ><dt ><a name="JoinThread-join" ><strong >join</strong></a>(self, timeout=None)</dt><dd ><tt >Wait until the thread terminates.<br />
|
||||
<br />
|
||||
This blocks the calling thread until the thread whose <a href="#JoinThread-join" >join</a>() method is<br />
|
||||
called terminates -- either normally or through an unhandled exception<br />
|
||||
or until the optional timeout occurs.<br />
|
||||
<br />
|
||||
When the timeout argument is present and not None, it should be a<br />
|
||||
floating point number specifying a timeout for the operation in seconds<br />
|
||||
(or fractions thereof). As <a href="#JoinThread-join" >join</a>() always returns None, you must call<br />
|
||||
<a href="#JoinThread-isAlive" >isAlive</a>() after <a href="#JoinThread-join" >join</a>() to decide whether a timeout happened -- if the<br />
|
||||
thread is still alive, the <a href="#JoinThread-join" >join</a>() call timed out.<br />
|
||||
<br />
|
||||
When the timeout argument is not present or None, the operation will<br />
|
||||
block until the thread terminates.<br />
|
||||
<br />
|
||||
A thread can be <a href="#JoinThread-join" >join</a>()ed many times.<br />
|
||||
<br />
|
||||
<a href="#JoinThread-join" >join</a>() raises a RuntimeError if an attempt is made to join the current<br />
|
||||
thread as that would cause a deadlock. It is also an error to <a href="#JoinThread-join" >join</a>() a<br />
|
||||
thread before it has been started and attempts to do so raises the same<br />
|
||||
exception.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-setDaemon"><strong>setDaemon</strong></a>(self, daemonic)</dt></dl>
|
||||
<dl ><dt ><a name="JoinThread-setDaemon" ><strong >setDaemon</strong></a>(self, daemonic)</dt></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-setName"><strong>setName</strong></a>(self, name)</dt></dl>
|
||||
<dl ><dt ><a name="JoinThread-setName" ><strong >setName</strong></a>(self, name)</dt></dl>
|
||||
|
||||
<dl><dt><a name="JoinThread-start"><strong>start</strong></a>(self)</dt><dd><tt>Start the thread's activity.<br>
|
||||
<br>
|
||||
It must be called at most once per thread object. It arranges for the<br>
|
||||
object's <a href="#JoinThread-run">run</a>() method to be invoked in a separate thread of control.<br>
|
||||
<br>
|
||||
This method will raise a RuntimeError if called more than once on the<br>
|
||||
<dl ><dt ><a name="JoinThread-start" ><strong >start</strong></a>(self)</dt><dd ><tt >Start the thread's activity.<br />
|
||||
<br />
|
||||
It must be called at most once per thread object. It arranges for the<br />
|
||||
object's <a href="#JoinThread-run" >run</a>() method to be invoked in a separate thread of control.<br />
|
||||
<br />
|
||||
This method will raise a RuntimeError if called more than once on the<br />
|
||||
same thread object.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
<hr />
|
||||
Data descriptors inherited from <a href="threading.html#Thread" >threading.Thread</a>:<br />
|
||||
<dl ><dt ><strong >__dict__</strong></dt>
|
||||
<dd ><tt >dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
<dl ><dt ><strong >__weakref__</strong></dt>
|
||||
<dd ><tt >list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>daemon</strong></dt>
|
||||
<dd><tt>A boolean value indicating whether this thread is a daemon thread.<br>
|
||||
<br>
|
||||
This must be set before start() is called, otherwise RuntimeError is<br>
|
||||
raised. Its initial value is inherited from the creating thread; the<br>
|
||||
main thread is not a daemon thread and therefore all threads created in<br>
|
||||
the main thread default to daemon = False.<br>
|
||||
<br>
|
||||
The entire Python program exits when no alive non-daemon threads are<br>
|
||||
<dl ><dt ><strong >daemon</strong></dt>
|
||||
<dd ><tt >A boolean value indicating whether this thread is a daemon thread.<br />
|
||||
<br />
|
||||
This must be set before start() is called, otherwise RuntimeError is<br />
|
||||
raised. Its initial value is inherited from the creating thread; the<br />
|
||||
main thread is not a daemon thread and therefore all threads created in<br />
|
||||
the main thread default to daemon = False.<br />
|
||||
<br />
|
||||
The entire Python program exits when no alive non-daemon threads are<br />
|
||||
left.</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>ident</strong></dt>
|
||||
<dd><tt>Thread identifier of this thread or None if it has not been started.<br>
|
||||
<br>
|
||||
This is a nonzero integer. See the thread.get_ident() function. Thread<br>
|
||||
identifiers may be recycled when a thread exits and another thread is<br>
|
||||
<dl ><dt ><strong >ident</strong></dt>
|
||||
<dd ><tt >Thread identifier of this thread or None if it has not been started.<br />
|
||||
<br />
|
||||
This is a nonzero integer. See the thread.get_ident() function. Thread<br />
|
||||
identifiers may be recycled when a thread exits and another thread is<br />
|
||||
created. The identifier is available even after the thread has exited.</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>name</strong></dt>
|
||||
<dd><tt>A string used for identification purposes only.<br>
|
||||
<br>
|
||||
It has no semantics. Multiple threads may be given the same name. The<br>
|
||||
<dl ><dt ><strong >name</strong></dt>
|
||||
<dd ><tt >A string used for identification purposes only.<br />
|
||||
<br />
|
||||
It has no semantics. Multiple threads may be given the same name. The<br />
|
||||
initial name is set by the constructor.</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="StoppableThread">class <strong>StoppableThread</strong></a>(<a href="threading.html#Thread">threading.Thread</a>)</font></td></tr>
|
||||
</td></tr></table> <p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ffc8d8" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#000000" face="helvetica, arial" ><a name="StoppableThread" >class <strong >StoppableThread</strong></a>(<a href="threading.html#Thread" >threading.Thread</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt><a href="#StoppableThread">StoppableThread</a> - A thread that can be stopped by forcing an exception in the execution context.<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="func_timeout.StoppableThread.html#StoppableThread">StoppableThread</a></dd>
|
||||
<dd><a href="threading.html#Thread">threading.Thread</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
<tr bgcolor="#ffc8d8" ><td rowspan="2" ><tt > </tt></td>
|
||||
<td colspan="2" ><tt ><a href="#StoppableThread" >StoppableThread</a> - A thread that can be stopped by forcing an exception in the execution context.<br /> </tt></td></tr>
|
||||
<tr ><td > </td>
|
||||
<td width="100%" ><dl ><dt >Method resolution order:</dt>
|
||||
<dd ><a href="func_timeout.StoppableThread.html#StoppableThread" >StoppableThread</a></dd>
|
||||
<dd ><a href="threading.html#Thread" >threading.Thread</a></dd>
|
||||
<dd ><a href="builtins.html#object" >builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
||||
<dl><dt><a name="StoppableThread-__init__"><strong>__init__</strong></a>(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)</dt><dd><tt>This constructor should always be called with keyword arguments. Arguments are:<br>
|
||||
<br>
|
||||
*group* should be None; reserved for future extension when a ThreadGroup<br>
|
||||
class is implemented.<br>
|
||||
<br>
|
||||
*target* is the callable object to be invoked by the <a href="#StoppableThread-run">run</a>()<br>
|
||||
method. Defaults to None, meaning nothing is called.<br>
|
||||
<br>
|
||||
*name* is the thread name. By default, a unique name is constructed of<br>
|
||||
the form "<a href="threading.html#Thread">Thread</a>-N" where N is a small decimal number.<br>
|
||||
<br>
|
||||
*args* is the argument tuple for the target invocation. Defaults to ().<br>
|
||||
<br>
|
||||
*kwargs* is a dictionary of keyword arguments for the target<br>
|
||||
invocation. Defaults to {}.<br>
|
||||
<br>
|
||||
If a subclass overrides the constructor, it must make sure to invoke<br>
|
||||
the base class constructor (<a href="threading.html#Thread">Thread</a>.<a href="#StoppableThread-__init__">__init__</a>()) before doing anything<br>
|
||||
<hr />
|
||||
Methods inherited from <a href="threading.html#Thread" >threading.Thread</a>:<br />
|
||||
<dl ><dt ><a name="StoppableThread-__init__" ><strong >__init__</strong></a>(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)</dt><dd ><tt >This constructor should always be called with keyword arguments. Arguments are:<br />
|
||||
<br />
|
||||
*group* should be None; reserved for future extension when a ThreadGroup<br />
|
||||
class is implemented.<br />
|
||||
<br />
|
||||
*target* is the callable object to be invoked by the <a href="#StoppableThread-run" >run</a>()<br />
|
||||
method. Defaults to None, meaning nothing is called.<br />
|
||||
<br />
|
||||
*name* is the thread name. By default, a unique name is constructed of<br />
|
||||
the form "<a href="threading.html#Thread" >Thread</a>-N" where N is a small decimal number.<br />
|
||||
<br />
|
||||
*args* is the argument tuple for the target invocation. Defaults to ().<br />
|
||||
<br />
|
||||
*kwargs* is a dictionary of keyword arguments for the target<br />
|
||||
invocation. Defaults to {}.<br />
|
||||
<br />
|
||||
If a subclass overrides the constructor, it must make sure to invoke<br />
|
||||
the base class constructor (<a href="threading.html#Thread" >Thread</a>.<a href="#StoppableThread-__init__" >__init__</a>()) before doing anything<br />
|
||||
else to the thread.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
<dl ><dt ><a name="StoppableThread-__repr__" ><strong >__repr__</strong></a>(self)</dt><dd ><tt >Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-getName"><strong>getName</strong></a>(self)</dt></dl>
|
||||
<dl ><dt ><a name="StoppableThread-getName" ><strong >getName</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-isAlive"><strong>isAlive</strong></a> = is_alive(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
||||
<br>
|
||||
This method returns True just before the <a href="#StoppableThread-run">run</a>() method starts until just<br>
|
||||
after the <a href="#StoppableThread-run">run</a>() method terminates. The module function enumerate()<br>
|
||||
<dl ><dt ><a name="StoppableThread-isAlive" ><strong >isAlive</strong></a> = is_alive(self)</dt><dd ><tt >Return whether the thread is alive.<br />
|
||||
<br />
|
||||
This method returns True just before the <a href="#StoppableThread-run" >run</a>() method starts until just<br />
|
||||
after the <a href="#StoppableThread-run" >run</a>() method terminates. The module function enumerate()<br />
|
||||
returns a list of all alive threads.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-isDaemon"><strong>isDaemon</strong></a>(self)</dt></dl>
|
||||
<dl ><dt ><a name="StoppableThread-isDaemon" ><strong >isDaemon</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-is_alive"><strong>is_alive</strong></a>(self)</dt><dd><tt>Return whether the thread is alive.<br>
|
||||
<br>
|
||||
This method returns True just before the <a href="#StoppableThread-run">run</a>() method starts until just<br>
|
||||
after the <a href="#StoppableThread-run">run</a>() method terminates. The module function enumerate()<br>
|
||||
<dl ><dt ><a name="StoppableThread-is_alive" ><strong >is_alive</strong></a>(self)</dt><dd ><tt >Return whether the thread is alive.<br />
|
||||
<br />
|
||||
This method returns True just before the <a href="#StoppableThread-run" >run</a>() method starts until just<br />
|
||||
after the <a href="#StoppableThread-run" >run</a>() method terminates. The module function enumerate()<br />
|
||||
returns a list of all alive threads.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-join"><strong>join</strong></a>(self, timeout=None)</dt><dd><tt>Wait until the thread terminates.<br>
|
||||
<br>
|
||||
This blocks the calling thread until the thread whose <a href="#StoppableThread-join">join</a>() method is<br>
|
||||
called terminates -- either normally or through an unhandled exception<br>
|
||||
or until the optional timeout occurs.<br>
|
||||
<br>
|
||||
When the timeout argument is present and not None, it should be a<br>
|
||||
floating point number specifying a timeout for the operation in seconds<br>
|
||||
(or fractions thereof). As <a href="#StoppableThread-join">join</a>() always returns None, you must call<br>
|
||||
<a href="#StoppableThread-isAlive">isAlive</a>() after <a href="#StoppableThread-join">join</a>() to decide whether a timeout happened -- if the<br>
|
||||
thread is still alive, the <a href="#StoppableThread-join">join</a>() call timed out.<br>
|
||||
<br>
|
||||
When the timeout argument is not present or None, the operation will<br>
|
||||
block until the thread terminates.<br>
|
||||
<br>
|
||||
A thread can be <a href="#StoppableThread-join">join</a>()ed many times.<br>
|
||||
<br>
|
||||
<a href="#StoppableThread-join">join</a>() raises a RuntimeError if an attempt is made to join the current<br>
|
||||
thread as that would cause a deadlock. It is also an error to <a href="#StoppableThread-join">join</a>() a<br>
|
||||
thread before it has been started and attempts to do so raises the same<br>
|
||||
<dl ><dt ><a name="StoppableThread-join" ><strong >join</strong></a>(self, timeout=None)</dt><dd ><tt >Wait until the thread terminates.<br />
|
||||
<br />
|
||||
This blocks the calling thread until the thread whose <a href="#StoppableThread-join" >join</a>() method is<br />
|
||||
called terminates -- either normally or through an unhandled exception<br />
|
||||
or until the optional timeout occurs.<br />
|
||||
<br />
|
||||
When the timeout argument is present and not None, it should be a<br />
|
||||
floating point number specifying a timeout for the operation in seconds<br />
|
||||
(or fractions thereof). As <a href="#StoppableThread-join" >join</a>() always returns None, you must call<br />
|
||||
<a href="#StoppableThread-isAlive" >isAlive</a>() after <a href="#StoppableThread-join" >join</a>() to decide whether a timeout happened -- if the<br />
|
||||
thread is still alive, the <a href="#StoppableThread-join" >join</a>() call timed out.<br />
|
||||
<br />
|
||||
When the timeout argument is not present or None, the operation will<br />
|
||||
block until the thread terminates.<br />
|
||||
<br />
|
||||
A thread can be <a href="#StoppableThread-join" >join</a>()ed many times.<br />
|
||||
<br />
|
||||
<a href="#StoppableThread-join" >join</a>() raises a RuntimeError if an attempt is made to join the current<br />
|
||||
thread as that would cause a deadlock. It is also an error to <a href="#StoppableThread-join" >join</a>() a<br />
|
||||
thread before it has been started and attempts to do so raises the same<br />
|
||||
exception.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-run"><strong>run</strong></a>(self)</dt><dd><tt>Method representing the thread's activity.<br>
|
||||
<br>
|
||||
You may override this method in a subclass. The standard <a href="#StoppableThread-run">run</a>() method<br>
|
||||
invokes the callable object passed to the object's constructor as the<br>
|
||||
target argument, if any, with sequential and keyword arguments taken<br>
|
||||
<dl ><dt ><a name="StoppableThread-run" ><strong >run</strong></a>(self)</dt><dd ><tt >Method representing the thread's activity.<br />
|
||||
<br />
|
||||
You may override this method in a subclass. The standard <a href="#StoppableThread-run" >run</a>() method<br />
|
||||
invokes the callable object passed to the object's constructor as the<br />
|
||||
target argument, if any, with sequential and keyword arguments taken<br />
|
||||
from the args and kwargs arguments, respectively.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-setDaemon"><strong>setDaemon</strong></a>(self, daemonic)</dt></dl>
|
||||
<dl ><dt ><a name="StoppableThread-setDaemon" ><strong >setDaemon</strong></a>(self, daemonic)</dt></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-setName"><strong>setName</strong></a>(self, name)</dt></dl>
|
||||
<dl ><dt ><a name="StoppableThread-setName" ><strong >setName</strong></a>(self, name)</dt></dl>
|
||||
|
||||
<dl><dt><a name="StoppableThread-start"><strong>start</strong></a>(self)</dt><dd><tt>Start the thread's activity.<br>
|
||||
<br>
|
||||
It must be called at most once per thread object. It arranges for the<br>
|
||||
object's <a href="#StoppableThread-run">run</a>() method to be invoked in a separate thread of control.<br>
|
||||
<br>
|
||||
This method will raise a RuntimeError if called more than once on the<br>
|
||||
<dl ><dt ><a name="StoppableThread-start" ><strong >start</strong></a>(self)</dt><dd ><tt >Start the thread's activity.<br />
|
||||
<br />
|
||||
It must be called at most once per thread object. It arranges for the<br />
|
||||
object's <a href="#StoppableThread-run" >run</a>() method to be invoked in a separate thread of control.<br />
|
||||
<br />
|
||||
This method will raise a RuntimeError if called more than once on the<br />
|
||||
same thread object.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="threading.html#Thread">threading.Thread</a>:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
<hr />
|
||||
Data descriptors inherited from <a href="threading.html#Thread" >threading.Thread</a>:<br />
|
||||
<dl ><dt ><strong >__dict__</strong></dt>
|
||||
<dd ><tt >dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
<dl ><dt ><strong >__weakref__</strong></dt>
|
||||
<dd ><tt >list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>daemon</strong></dt>
|
||||
<dd><tt>A boolean value indicating whether this thread is a daemon thread.<br>
|
||||
<br>
|
||||
This must be set before start() is called, otherwise RuntimeError is<br>
|
||||
raised. Its initial value is inherited from the creating thread; the<br>
|
||||
main thread is not a daemon thread and therefore all threads created in<br>
|
||||
the main thread default to daemon = False.<br>
|
||||
<br>
|
||||
The entire Python program exits when no alive non-daemon threads are<br>
|
||||
<dl ><dt ><strong >daemon</strong></dt>
|
||||
<dd ><tt >A boolean value indicating whether this thread is a daemon thread.<br />
|
||||
<br />
|
||||
This must be set before start() is called, otherwise RuntimeError is<br />
|
||||
raised. Its initial value is inherited from the creating thread; the<br />
|
||||
main thread is not a daemon thread and therefore all threads created in<br />
|
||||
the main thread default to daemon = False.<br />
|
||||
<br />
|
||||
The entire Python program exits when no alive non-daemon threads are<br />
|
||||
left.</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>ident</strong></dt>
|
||||
<dd><tt>Thread identifier of this thread or None if it has not been started.<br>
|
||||
<br>
|
||||
This is a nonzero integer. See the thread.get_ident() function. Thread<br>
|
||||
identifiers may be recycled when a thread exits and another thread is<br>
|
||||
<dl ><dt ><strong >ident</strong></dt>
|
||||
<dd ><tt >Thread identifier of this thread or None if it has not been started.<br />
|
||||
<br />
|
||||
This is a nonzero integer. See the thread.get_ident() function. Thread<br />
|
||||
identifiers may be recycled when a thread exits and another thread is<br />
|
||||
created. The identifier is available even after the thread has exited.</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>name</strong></dt>
|
||||
<dd><tt>A string used for identification purposes only.<br>
|
||||
<br>
|
||||
It has no semantics. Multiple threads may be given the same name. The<br>
|
||||
<dl ><dt ><strong >name</strong></dt>
|
||||
<dd ><tt >A string used for identification purposes only.<br />
|
||||
<br />
|
||||
It has no semantics. Multiple threads may be given the same name. The<br />
|
||||
initial name is set by the constructor.</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
||||
</td></tr></table></p></p></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#55aa55" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Data</strong></big></font></td></tr>
|
||||
|
||||
<tr ><td bgcolor="#55aa55" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><strong >__all__</strong> = ('StoppableThread', 'JoinThread')</td></tr></table>
|
||||
</p></p></p></body></html>
|
||||
@ -1,59 +1,116 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module func_timeout.dafunc</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
<html ><head ><title >Python: module func_timeout.dafunc</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head><body bgcolor="#f0f0f8" >
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <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><tt>Copyright (c) 2016 Tim Savannah All Rights Reserved.<br>
|
||||
<br>
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br>
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="heading" >
|
||||
<tr bgcolor="#7799ee" >
|
||||
<td valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" > <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 ><tt >Copyright (c) 2016, 2017 Tim Savannah All Rights Reserved.<br />
|
||||
<br />
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br />
|
||||
LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE</tt></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#aa55cc" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="threading.html">threading</a><br>
|
||||
</td><td width="25%" valign=top><a href="time.html">time</a><br>
|
||||
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
<tr ><td bgcolor="#aa55cc" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><table width="100%" summary="list" ><tr ><td width="25%" valign="top" ><a href="copy.html" >copy</a><br />
|
||||
<a href="inspect.html" >inspect</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="threading.html" >threading</a><br />
|
||||
<a href="time.html" >time</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="types.html" >types</a><br />
|
||||
</td><td width="25%" valign="top" ></td></tr></table></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#eeaa77" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-func_timeout"><strong>func_timeout</strong></a>(timeout, func, args=(), kwargs=None)</dt><dd><tt>func_timeout - Runs the given function for up to #timeout# seconds.<br>
|
||||
<br>
|
||||
Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises FunctionTimedOut<br>
|
||||
<br>
|
||||
@param timeout <float> - Maximum number of seconds to run #func# before terminating<br>
|
||||
@param func <function> - The function to call<br>
|
||||
@param args <tuple> - Any ordered arguments to pass to the function<br>
|
||||
@param kwargs <dict/None> - Keyword arguments to pass to the function.<br>
|
||||
<br>
|
||||
@raises - FunctionTimedOut if #timeout# is exceeded, otherwise anything #func# could raise will be raised<br>
|
||||
<br>
|
||||
If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates,<br>
|
||||
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except FunctionTimedOut<br>
|
||||
to return cleanly, but in most cases it will 'just work'.<br>
|
||||
<br>
|
||||
Be careful of code like:<br>
|
||||
def myfunc():<br>
|
||||
while True:<br>
|
||||
try:<br>
|
||||
dosomething()<br>
|
||||
except Exception:<br>
|
||||
continue<br>
|
||||
<br>
|
||||
because it will never terminate.<br>
|
||||
<br>
|
||||
<tr ><td bgcolor="#eeaa77" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><dl ><dt ><a name="-func_set_timeout" ><strong >func_set_timeout</strong></a>(timeout, allowOverride=False)</dt><dd ><tt >set_timeout - Wrapper to run a function with a given/calculated timeout (max execution time).<br />
|
||||
Optionally (if #allowOverride is True), adds a paramater, "forceTimeout", to the<br />
|
||||
function which, if provided, will override the default timeout for that invocation.<br />
|
||||
<br />
|
||||
If #timeout is provided as a lambda/function, it will be called<br />
|
||||
prior to each invocation of the decorated function to calculate the timeout to be used<br />
|
||||
for that call, based on the arguments passed to the decorated function.<br />
|
||||
<br />
|
||||
For example, you may have a "processData" function whose execution time<br />
|
||||
depends on the number of "data" elements, so you may want a million elements to have a <br />
|
||||
much higher timeout than seven elements.)<br />
|
||||
<br />
|
||||
If #allowOverride is True AND a kwarg of "forceTimeout" is passed to the wrapped function, that timeout<br />
|
||||
will be used for that single call.<br />
|
||||
<br />
|
||||
@param timeout <float OR lambda/function> - <br />
|
||||
<br />
|
||||
**If float:**<br />
|
||||
Default number of seconds max to allow function to execute<br />
|
||||
before throwing FunctionTimedOut<br />
|
||||
<br />
|
||||
**If lambda/function:<br />
|
||||
<br />
|
||||
If a function/lambda is provided, it will be called for every<br />
|
||||
invocation of the decorated function (unless #allowOverride=True and "forceTimeout" was passed) <br />
|
||||
to determine the timeout to use based on the arguments to the decorated function.<br />
|
||||
<br />
|
||||
The arguments as passed into the decorated function will be passed to this function.<br />
|
||||
They either must match exactly to what the decorated function has, OR<br />
|
||||
if you prefer to get the *args (list of ordered args) and **kwargs ( key : value keyword args form),<br />
|
||||
define your calculate function like:<br />
|
||||
<br />
|
||||
def calculateTimeout(*args, **kwargs):<br />
|
||||
...<br />
|
||||
<br />
|
||||
or lambda like:<br />
|
||||
<br />
|
||||
calculateTimeout = lambda *args, **kwargs : ...<br />
|
||||
<br />
|
||||
otherwise the args to your calculate function should match exactly the decorated function.<br />
|
||||
<br />
|
||||
<br />
|
||||
@param allowOverride <bool> Default False, if True adds a keyword argument to the decorated function,<br />
|
||||
"forceTimeout" which, if provided, will override the #timeout. If #timeout was provided as a lambda / function, it<br />
|
||||
will not be called.<br />
|
||||
<br />
|
||||
@throws FunctionTimedOut If time alloted passes without function returning naturally<br />
|
||||
<br />
|
||||
@see func_timeout</tt></dd></dl>
|
||||
<dl ><dt ><a name="-func_timeout" ><strong >func_timeout</strong></a>(timeout, func, args=(), kwargs=None)</dt><dd ><tt >func_timeout - Runs the given function for up to #timeout# seconds.<br />
|
||||
<br />
|
||||
Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises FunctionTimedOut<br />
|
||||
<br />
|
||||
@param timeout <float> - Maximum number of seconds to run #func# before terminating<br />
|
||||
@param func <function> - The function to call<br />
|
||||
@param args <tuple> - Any ordered arguments to pass to the function<br />
|
||||
@param kwargs <dict/None> - Keyword arguments to pass to the function.<br />
|
||||
<br />
|
||||
@raises - FunctionTimedOut if #timeout# is exceeded, otherwise anything #func# could raise will be raised<br />
|
||||
<br />
|
||||
If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates,<br />
|
||||
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except FunctionTimedOut<br />
|
||||
to return cleanly, but in most cases it will 'just work'.<br />
|
||||
<br />
|
||||
Be careful of code like:<br />
|
||||
def myfunc():<br />
|
||||
while True:<br />
|
||||
try:<br />
|
||||
dosomething()<br />
|
||||
except Exception:<br />
|
||||
continue<br />
|
||||
<br />
|
||||
because it will never terminate.<br />
|
||||
<br />
|
||||
@return - The return value that #func# gives</tt></dd></dl>
|
||||
</td></tr></table>
|
||||
</body></html>
|
||||
</td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#55aa55" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Data</strong></big></font></td></tr>
|
||||
|
||||
<tr ><td bgcolor="#55aa55" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><strong >__all__</strong> = ('func_timeout', 'func_set_timeout')</td></tr></table>
|
||||
</p></p></p></body></html>
|
||||
@ -1,87 +1,120 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module func_timeout.exceptions</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
<html ><head ><title >Python: module func_timeout.exceptions</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head><body bgcolor="#f0f0f8" >
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="func_timeout.html"><font color="#ffffff">func_timeout</font></a>.exceptions</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>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="heading" >
|
||||
<tr bgcolor="#7799ee" >
|
||||
<td valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" > <br /><big ><big ><strong ><a href="func_timeout.html" ><font color="#ffffff" >func_timeout</font></a>.exceptions</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 ><tt >Copyright (c) 2016 Tim Savannah All Rights Reserved.<br />
|
||||
<br />
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br />
|
||||
LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE</tt></p>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ee77aa" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#BaseException">builtins.BaseException</a>(<a href="builtins.html#object">builtins.object</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="func_timeout.exceptions.html#FunctionTimedOut">FunctionTimedOut</a>
|
||||
<tr ><td bgcolor="#ee77aa" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="builtins.html#BaseException" >builtins.BaseException</a>(<a href="builtins.html#object" >builtins.object</a>)
|
||||
</font></dt><dd >
|
||||
<dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="func_timeout.exceptions.html#FunctionTimedOut" >FunctionTimedOut</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<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>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ffc8d8" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<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> </tt></td>
|
||||
<td colspan=2><tt>Common base class for all exceptions<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="func_timeout.exceptions.html#FunctionTimedOut">FunctionTimedOut</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
<tr bgcolor="#ffc8d8" ><td rowspan="2" ><tt > </tt></td>
|
||||
<td colspan="2" ><tt ><a href="#FunctionTimedOut" >FunctionTimedOut</a> - Exception raised when a function times out<br />
|
||||
<br />
|
||||
@property timedOutAfter - Number of seconds before timeout was triggered<br />
|
||||
<br />
|
||||
@property timedOutFunction - Function called which timed out<br />
|
||||
@property timedOutArgs - Ordered args to function<br />
|
||||
@property timedOutKwargs - Keyword args to function<br />
|
||||
<br />
|
||||
@method retry - R<br /> </tt></td></tr>
|
||||
<tr ><td > </td>
|
||||
<td width="100%" ><dl ><dt >Method resolution order:</dt>
|
||||
<dd ><a href="func_timeout.exceptions.html#FunctionTimedOut" >FunctionTimedOut</a></dd>
|
||||
<dd ><a href="builtins.html#BaseException" >builtins.BaseException</a></dd>
|
||||
<dd ><a href="builtins.html#object" >builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
<hr />
|
||||
Methods defined here:<br />
|
||||
<dl ><dt ><a name="FunctionTimedOut-__init__" ><strong >__init__</strong></a>(self, msg='', timedOutAfter=None, timedOutFunction=None, timedOutArgs=None, timedOutKwargs=None)</dt><dd ><tt >Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl ><dt ><a name="FunctionTimedOut-getMsg" ><strong >getMsg</strong></a>(self)</dt><dd ><tt >getMsg - Generate a default message based on parameters to <a href="#FunctionTimedOut" >FunctionTimedOut</a> exception'<br />
|
||||
<br />
|
||||
@return <str> - Message</tt></dd></dl>
|
||||
|
||||
<dl ><dt ><a name="FunctionTimedOut-retry" ><strong >retry</strong></a>(self, timeout='__rst')</dt><dd ><tt >retry - Retry the timed-out function with same arguments.<br />
|
||||
<br />
|
||||
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT<br />
|
||||
<br />
|
||||
If RETRY_SAME_TIMEOUT : Will retry the function same args, sane timeout<br />
|
||||
If a float/int : Will retry the function same args with provided timeout<br />
|
||||
If None : Will retry function same args no timeout<br />
|
||||
<br />
|
||||
@return - Returnval from function</tt></dd></dl>
|
||||
|
||||
<hr />
|
||||
Data descriptors defined here:<br />
|
||||
<dl ><dt ><strong >__weakref__</strong></dt>
|
||||
<dd ><tt >list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="FunctionTimedOut-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
<hr />
|
||||
Methods inherited from <a href="builtins.html#BaseException" >builtins.BaseException</a>:<br />
|
||||
<dl ><dt ><a name="FunctionTimedOut-__delattr__" ><strong >__delattr__</strong></a>(self, name, /)</dt><dd ><tt >Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__getattribute__" ><strong >__getattribute__</strong></a>(self, name, /)</dt><dd ><tt >Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__new__" ><strong >__new__</strong></a>(*args, **kwargs)<font color="#909090" ><font face="helvetica, arial" > from <a href="builtins.html#type" >builtins.type</a></font></font></dt><dd ><tt >Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__reduce__" ><strong >__reduce__</strong></a>(...)</dt><dd ><tt >helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__repr__" ><strong >__repr__</strong></a>(self, /)</dt><dd ><tt >Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__setattr__" ><strong >__setattr__</strong></a>(self, name, value, /)</dt><dd ><tt >Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__setstate__" ><strong >__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__str__" ><strong >__str__</strong></a>(self, /)</dt><dd ><tt >Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-with_traceback" ><strong >with_traceback</strong></a>(...)</dt><dd ><tt >Exception.<a href="#FunctionTimedOut-with_traceback" >with_traceback</a>(tb) --<br />
|
||||
set self.<strong >__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#FunctionTimedOut-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
<hr />
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException" >builtins.BaseException</a>:<br />
|
||||
<dl ><dt ><strong >__cause__</strong></dt>
|
||||
<dd ><tt >exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
<dl ><dt ><strong >__context__</strong></dt>
|
||||
<dd ><tt >exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dl ><dt ><strong >__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
<dl ><dt ><strong >__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
<dl ><dt ><strong >__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
<dl ><dt ><strong >args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
||||
</td></tr></table></p></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#55aa55" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Data</strong></big></font></td></tr>
|
||||
|
||||
<tr ><td bgcolor="#55aa55" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><strong >RETRY_SAME_TIMEOUT</strong> = '__rst'<br />
|
||||
<strong >__all__</strong> = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT')</td></tr></table>
|
||||
</p></p></body></html>
|
||||
@ -1,141 +1,212 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: package func_timeout</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
<html ><head ><title >Python: package func_timeout</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head><body bgcolor="#f0f0f8" >
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>func_timeout</strong></big></big> (version 3.1.0)</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 (c) 2016 Tim Savannah All Rights Reserved.<br>
|
||||
<br>
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br>
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="heading" >
|
||||
<tr bgcolor="#7799ee" >
|
||||
<td valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" > <br /><big ><big ><strong >func_timeout</strong></big></big> (version 4.0.0)</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 (c) 2016, 2017 Tim Savannah All Rights Reserved.<br />
|
||||
<br />
|
||||
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as<br />
|
||||
LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE</tt></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#aa55cc" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Package Contents</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="func_timeout.StoppableThread.html">StoppableThread</a><br>
|
||||
</td><td width="25%" valign=top><a href="func_timeout.dafunc.html">dafunc</a><br>
|
||||
</td><td width="25%" valign=top><a href="func_timeout.exceptions.html">exceptions</a><br>
|
||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
<tr ><td bgcolor="#aa55cc" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><table width="100%" summary="list" ><tr ><td width="25%" valign="top" ><a href="func_timeout.StoppableThread.html" >StoppableThread</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="func_timeout.dafunc.html" >dafunc</a><br />
|
||||
</td><td width="25%" valign="top" ><a href="func_timeout.exceptions.html" >exceptions</a><br />
|
||||
</td><td width="25%" valign="top" ></td></tr></table></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ee77aa" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#BaseException">builtins.BaseException</a>(<a href="builtins.html#object">builtins.object</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="func_timeout.exceptions.html#FunctionTimedOut">func_timeout.exceptions.FunctionTimedOut</a>
|
||||
<tr ><td bgcolor="#ee77aa" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="builtins.html#BaseException" >builtins.BaseException</a>(<a href="builtins.html#object" >builtins.object</a>)
|
||||
</font></dt><dd >
|
||||
<dl >
|
||||
<dt ><font face="helvetica, arial" ><a href="func_timeout.exceptions.html#FunctionTimedOut" >func_timeout.exceptions.FunctionTimedOut</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<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>
|
||||
<p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#ffc8d8" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<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> </tt></td>
|
||||
<td colspan=2><tt><a href="#FunctionTimedOut">FunctionTimedOut</a> - Exception raised when a function times out<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="func_timeout.exceptions.html#FunctionTimedOut">FunctionTimedOut</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
<tr bgcolor="#ffc8d8" ><td rowspan="2" ><tt > </tt></td>
|
||||
<td colspan="2" ><tt ><a href="#FunctionTimedOut" >FunctionTimedOut</a> - Exception raised when a function times out<br />
|
||||
<br />
|
||||
@property timedOutAfter - Number of seconds before timeout was triggered<br />
|
||||
<br />
|
||||
@property timedOutFunction - Function called which timed out<br />
|
||||
@property timedOutArgs - Ordered args to function<br />
|
||||
@property timedOutKwargs - Keyword args to function<br />
|
||||
<br />
|
||||
@method retry - R<br /> </tt></td></tr>
|
||||
<tr ><td > </td>
|
||||
<td width="100%" ><dl ><dt >Method resolution order:</dt>
|
||||
<dd ><a href="func_timeout.exceptions.html#FunctionTimedOut" >FunctionTimedOut</a></dd>
|
||||
<dd ><a href="builtins.html#BaseException" >builtins.BaseException</a></dd>
|
||||
<dd ><a href="builtins.html#object" >builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
<hr />
|
||||
Methods defined here:<br />
|
||||
<dl ><dt ><a name="FunctionTimedOut-__init__" ><strong >__init__</strong></a>(self, msg='', timedOutAfter=None, timedOutFunction=None, timedOutArgs=None, timedOutKwargs=None)</dt><dd ><tt >Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl ><dt ><a name="FunctionTimedOut-getMsg" ><strong >getMsg</strong></a>(self)</dt><dd ><tt >getMsg - Generate a default message based on parameters to <a href="#FunctionTimedOut" >FunctionTimedOut</a> exception'<br />
|
||||
<br />
|
||||
@return <str> - Message</tt></dd></dl>
|
||||
|
||||
<dl ><dt ><a name="FunctionTimedOut-retry" ><strong >retry</strong></a>(self, timeout='__rst')</dt><dd ><tt >retry - Retry the timed-out function with same arguments.<br />
|
||||
<br />
|
||||
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT<br />
|
||||
<br />
|
||||
If RETRY_SAME_TIMEOUT : Will retry the function same args, sane timeout<br />
|
||||
If a float/int : Will retry the function same args with provided timeout<br />
|
||||
If None : Will retry function same args no timeout<br />
|
||||
<br />
|
||||
@return - Returnval from function</tt></dd></dl>
|
||||
|
||||
<hr />
|
||||
Data descriptors defined here:<br />
|
||||
<dl ><dt ><strong >__weakref__</strong></dt>
|
||||
<dd ><tt >list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="FunctionTimedOut-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
<hr />
|
||||
Methods inherited from <a href="builtins.html#BaseException" >builtins.BaseException</a>:<br />
|
||||
<dl ><dt ><a name="FunctionTimedOut-__delattr__" ><strong >__delattr__</strong></a>(self, name, /)</dt><dd ><tt >Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__getattribute__" ><strong >__getattribute__</strong></a>(self, name, /)</dt><dd ><tt >Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__new__" ><strong >__new__</strong></a>(*args, **kwargs)<font color="#909090" ><font face="helvetica, arial" > from <a href="builtins.html#type" >builtins.type</a></font></font></dt><dd ><tt >Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__reduce__" ><strong >__reduce__</strong></a>(...)</dt><dd ><tt >helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__repr__" ><strong >__repr__</strong></a>(self, /)</dt><dd ><tt >Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__setattr__" ><strong >__setattr__</strong></a>(self, name, value, /)</dt><dd ><tt >Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__setstate__" ><strong >__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-__str__" ><strong >__str__</strong></a>(self, /)</dt><dd ><tt >Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
<dl ><dt ><a name="FunctionTimedOut-with_traceback" ><strong >with_traceback</strong></a>(...)</dt><dd ><tt >Exception.<a href="#FunctionTimedOut-with_traceback" >with_traceback</a>(tb) --<br />
|
||||
set self.<strong >__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="FunctionTimedOut-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#FunctionTimedOut-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
<hr />
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException" >builtins.BaseException</a>:<br />
|
||||
<dl ><dt ><strong >__cause__</strong></dt>
|
||||
<dd ><tt >exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
<dl ><dt ><strong >__context__</strong></dt>
|
||||
<dd ><tt >exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dl ><dt ><strong >__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
<dl ><dt ><strong >__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
<dl ><dt ><strong >__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
<dl ><dt ><strong >args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
</td></tr></table></p></td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#eeaa77" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-func_timeout"><strong>func_timeout</strong></a>(timeout, func, args=(), kwargs=None)</dt><dd><tt>func_timeout - Runs the given function for up to #timeout# seconds.<br>
|
||||
<br>
|
||||
Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises <a href="#FunctionTimedOut">FunctionTimedOut</a><br>
|
||||
<br>
|
||||
@param timeout <float> - Maximum number of seconds to run #func# before terminating<br>
|
||||
@param func <function> - The function to call<br>
|
||||
@param args <tuple> - Any ordered arguments to pass to the function<br>
|
||||
@param kwargs <dict/None> - Keyword arguments to pass to the function.<br>
|
||||
<br>
|
||||
@raises - <a href="#FunctionTimedOut">FunctionTimedOut</a> if #timeout# is exceeded, otherwise anything #func# could raise will be raised<br>
|
||||
<br>
|
||||
If the timeout is exceeded, <a href="#FunctionTimedOut">FunctionTimedOut</a> will be raised within the context of the called function every two seconds until it terminates,<br>
|
||||
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except <a href="#FunctionTimedOut">FunctionTimedOut</a><br>
|
||||
to return cleanly, but in most cases it will 'just work'.<br>
|
||||
<br>
|
||||
Be careful of code like:<br>
|
||||
def myfunc():<br>
|
||||
while True:<br>
|
||||
try:<br>
|
||||
dosomething()<br>
|
||||
except Exception:<br>
|
||||
continue<br>
|
||||
<br>
|
||||
because it will never terminate.<br>
|
||||
<br>
|
||||
<tr ><td bgcolor="#eeaa77" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><dl ><dt ><a name="-func_set_timeout" ><strong >func_set_timeout</strong></a>(timeout, allowOverride=False)</dt><dd ><tt >set_timeout - Wrapper to run a function with a given/calculated timeout (max execution time).<br />
|
||||
Optionally (if #allowOverride is True), adds a paramater, "forceTimeout", to the<br />
|
||||
function which, if provided, will override the default timeout for that invocation.<br />
|
||||
<br />
|
||||
If #timeout is provided as a lambda/function, it will be called<br />
|
||||
prior to each invocation of the decorated function to calculate the timeout to be used<br />
|
||||
for that call, based on the arguments passed to the decorated function.<br />
|
||||
<br />
|
||||
For example, you may have a "processData" function whose execution time<br />
|
||||
depends on the number of "data" elements, so you may want a million elements to have a <br />
|
||||
much higher timeout than seven elements.)<br />
|
||||
<br />
|
||||
If #allowOverride is True AND a kwarg of "forceTimeout" is passed to the wrapped function, that timeout<br />
|
||||
will be used for that single call.<br />
|
||||
<br />
|
||||
@param timeout <float OR lambda/function> - <br />
|
||||
<br />
|
||||
**If float:**<br />
|
||||
Default number of seconds max to allow function to execute<br />
|
||||
before throwing <a href="#FunctionTimedOut" >FunctionTimedOut</a><br />
|
||||
<br />
|
||||
**If lambda/function:<br />
|
||||
<br />
|
||||
If a function/lambda is provided, it will be called for every<br />
|
||||
invocation of the decorated function (unless #allowOverride=True and "forceTimeout" was passed) <br />
|
||||
to determine the timeout to use based on the arguments to the decorated function.<br />
|
||||
<br />
|
||||
The arguments as passed into the decorated function will be passed to this function.<br />
|
||||
They either must match exactly to what the decorated function has, OR<br />
|
||||
if you prefer to get the *args (list of ordered args) and **kwargs ( key : value keyword args form),<br />
|
||||
define your calculate function like:<br />
|
||||
<br />
|
||||
def calculateTimeout(*args, **kwargs):<br />
|
||||
...<br />
|
||||
<br />
|
||||
or lambda like:<br />
|
||||
<br />
|
||||
calculateTimeout = lambda *args, **kwargs : ...<br />
|
||||
<br />
|
||||
otherwise the args to your calculate function should match exactly the decorated function.<br />
|
||||
<br />
|
||||
<br />
|
||||
@param allowOverride <bool> Default False, if True adds a keyword argument to the decorated function,<br />
|
||||
"forceTimeout" which, if provided, will override the #timeout. If #timeout was provided as a lambda / function, it<br />
|
||||
will not be called.<br />
|
||||
<br />
|
||||
@throws <a href="#FunctionTimedOut" >FunctionTimedOut</a> If time alloted passes without function returning naturally<br />
|
||||
<br />
|
||||
@see func_timeout</tt></dd></dl>
|
||||
<dl ><dt ><a name="-func_timeout" ><strong >func_timeout</strong></a>(timeout, func, args=(), kwargs=None)</dt><dd ><tt >func_timeout - Runs the given function for up to #timeout# seconds.<br />
|
||||
<br />
|
||||
Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises <a href="#FunctionTimedOut" >FunctionTimedOut</a><br />
|
||||
<br />
|
||||
@param timeout <float> - Maximum number of seconds to run #func# before terminating<br />
|
||||
@param func <function> - The function to call<br />
|
||||
@param args <tuple> - Any ordered arguments to pass to the function<br />
|
||||
@param kwargs <dict/None> - Keyword arguments to pass to the function.<br />
|
||||
<br />
|
||||
@raises - <a href="#FunctionTimedOut" >FunctionTimedOut</a> if #timeout# is exceeded, otherwise anything #func# could raise will be raised<br />
|
||||
<br />
|
||||
If the timeout is exceeded, <a href="#FunctionTimedOut" >FunctionTimedOut</a> will be raised within the context of the called function every two seconds until it terminates,<br />
|
||||
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except <a href="#FunctionTimedOut" >FunctionTimedOut</a><br />
|
||||
to return cleanly, but in most cases it will 'just work'.<br />
|
||||
<br />
|
||||
Be careful of code like:<br />
|
||||
def myfunc():<br />
|
||||
while True:<br />
|
||||
try:<br />
|
||||
dosomething()<br />
|
||||
except Exception:<br />
|
||||
continue<br />
|
||||
<br />
|
||||
because it will never terminate.<br />
|
||||
<br />
|
||||
@return - The return value that #func# gives</tt></dd></dl>
|
||||
</td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#55aa55">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||
</td></tr></table><p >
|
||||
<table width="100%" cellspacing="0" cellpadding="2" border="0" summary="section" >
|
||||
<tr bgcolor="#55aa55" >
|
||||
<td colspan="3" valign="bottom" > <br />
|
||||
<font color="#ffffff" face="helvetica, arial" ><big ><strong >Data</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><strong>__all__</strong> = ('func_timeout', 'FunctionTimedOut')<br>
|
||||
<strong>__version_tuple__</strong> = (3, 0, 1)</td></tr></table>
|
||||
</body></html>
|
||||
<tr ><td bgcolor="#55aa55" ><tt > </tt></td><td > </td>
|
||||
<td width="100%" ><strong >__all__</strong> = ('func_timeout', 'func_set_timeout', 'FunctionTimedOut')<br />
|
||||
<strong >__version_tuple__</strong> = (4, 0, 0)</td></tr></table>
|
||||
</p></p></p></p></body></html>
|
||||
1
doc/index.html
Symbolic link
1
doc/index.html
Symbolic link
@ -0,0 +1 @@
|
||||
func_timeout.html
|
||||
Loading…
Reference in New Issue
Block a user