<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>RepoView: Extra Packages for Bauman</title>
  <link href="layout/repostyle.css" type="text/css" rel="stylesheet" />
  <meta content="noindex,follow" name="robots" />
</head>
<body>
    <div class="levbar">
      <p class="pagetitle">cobra-gpl</p>
      <ul class="levbarlist">
        <li>
        <a href="cobra-gpl.group.html" class="nlink" title="Back to package listing">« Back to group</a>
    </li>
    </ul>
    </div>
    <div class="main">
        <p class="nav">Jump to letter: [
          <span class="letterlist">
            <a href="letter_a.group.html" class="nlink">  A  </a><a href="letter_c.group.html" class="nlink">  C  </a><a href="letter_d.group.html" class="nlink">  D  </a><a href="letter_e.group.html" class="nlink">  E  </a><a href="letter_f.group.html" class="nlink">  F  </a><a href="letter_g.group.html" class="nlink">  G  </a><a href="letter_j.group.html" class="nlink">  J  </a><a href="letter_l.group.html" class="nlink">  L  </a><a href="letter_m.group.html" class="nlink">  M  </a><a href="letter_p.group.html" class="nlink">  P  </a><a href="letter_r.group.html" class="nlink">  R  </a><a href="letter_s.group.html" class="nlink">  S  </a><a href="letter_t.group.html" class="nlink">  T  </a><a href="letter_u.group.html" class="nlink">  U  </a><a href="letter_y.group.html" class="nlink">  Y  </a>
          </span>]
        </p>
        <h2>python-interruptingcow - A watchdog that interrupts long running code.</h2>
        <table cellpadding="2" cellspacing="0" border="0">
          <tr>
            <th>Website:</th>
            <td><a href="https://bitbucket.org/evzijst/interruptingcow">https://bitbucket.org/evzijst/interruptingcow</a></td>
          </tr>
          <tr>
            <th>License:</th>
            <td>MIT</td>
          </tr>
          <tr>
            <th>Vendor:</th>
            <td>Erik van Zijst &lt;erik.van.zijst@gmail.com></td>
          </tr>
        </table>
        <dl>
        <dt>Description:</dt>
        <dd><pre>Interrupting Cow
================

Interruptingcow is a generic utility can relatively gracefully interrupt your
Python code when it doesn't execute within a specific number of seconds::

    from interruptingcow import timeout

    try:
        with timeout(5, exception=RuntimeError):
            
            pass
    except RuntimeError:
        print "didn't finish within 5 seconds"

Timeouts are specified in seconds (as floats with theoretical microsecond
precision).


Installation
------------
::

    $ pip install interruptingcow


Reentrant
---------

Interruptingcow is fully reentrant, which means that you can have nested
timeouts::

    from interruptingcow import timeout

    class Outer(RuntimeError): pass

    class Inner(RuntimeError): pass

    try:
        with timeout(20.0, Outer):
            try:
                with timeout(1.0, Inner):
                    
                    try_the_expensive_thing()
            except Inner:
                do_the_cheap_thing_instead()

    except Outer:
        print 'Program as a whole failed to return in 20 secs'

Nested timeouts allow a large outer timeout to contain smaller timeouts. If the
inner timeout is larger than the outer timeout, it is treated as a no-op.


Function Decorators
-------------------

Interruptingcow can be used both as inline with-statements, as shown in the
above examples, as well as function decorator::

    from interruptingcow import timeout

    @timeout(.5)
    def foo():
        with timeout(.3):
            
            pass


Caveats
-------

Interruptingcow uses ``signal(SIGALRM)`` to let the operating system interrupt
program execution. This has the following limitations:

1. Python signal handlers only apply to the main thread, so you cannot use this
   from other threads
2. You must not use this in a program that uses ``SIGALRM`` itself (this
   includes certain profilers)</pre></dd>
        </dl>
        <h3>Packages</h3>
        <table cellpadding="0" cellspacing="10" border="0">
        <tr>
            <td valign="top"><a href="../SRPMS/python-interruptingcow-0.6-1.el7.centos.src.rpm" class="inpage">python-interruptingcow-0.6-1.el7.centos.src</a>
              [<span style="white-space: nowrap">8 KiB</span>]</td>
            <td valign="top">
            	<em>(no changelog entry)</em>
            </td>
        </tr><tr>
            <td valign="top"><a href="../RPMS/noarch/python-interruptingcow-0.6-1.el7.centos.noarch.rpm" class="inpage">python-interruptingcow-0.6-1.el7.centos.noarch</a>
              [<span style="white-space: nowrap">9 KiB</span>]</td>
            <td valign="top">
            	<em>(no changelog entry)</em>
            </td>
        </tr>
        </table>
        <p class="footernote">
          Listing created by
          <a href="https://fedorahosted.org/repoview/" class="repoview">Repoview-0.6.6-4.el7</a>
        </p>
    </div>
</body>
</html>