Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
itimer | ||
======= | ||
|
||
The `itimer` module adds support for sub-second alarm signal delivery | ||
on systems that support `setitimer(2)` and `getitimer(2)`. Usage is | ||
very similar to sending alarm signals with the built-in `signal` module: | ||
|
||
import itimer | ||
import signal | ||
import time | ||
|
||
def handler(*args, **kwargs): | ||
print 'Alarm! (%s)' % time.time() | ||
|
||
def main(): | ||
signal.signal(signal.SIGALRM, handler) | ||
|
||
cont = True | ||
while cont: | ||
try: | ||
time.sleep(1) | ||
itimer.alarm(0.5) | ||
except KeyboardInterrupt: | ||
cont = False | ||
return 0 | ||
|
||
if __name__ == '__main__': | ||
exit(main()) | ||
|
||
(The example above will fire SIGALRM signals every 0.5s) | ||
|
||
|
||
License | ||
======== | ||
|
||
See the `LICENSE` file | ||
|
||
|
||
Authors | ||
========= | ||
|
||
`itimer` was originally written by Libor Michalek at [Slide, Inc.](http://github.com/slideinc) |