This file contains hidden or 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
| def shell(cmdline): | |
| start = time.time() | |
| outbuffer = StringIO.StringIO() | |
| print "asked to shell", cmdline | |
| subcommands = cmdline.split('|') | |
| subcommands = [command.strip() for command in subcommands] | |
| first, last, subcommands = subcommands[0], subcommands[-1], subcommands[1:-1] |
This file contains hidden or 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
| import signal | |
| import time | |
| class TimerException(Exception): pass | |
| from contextlib import contextmanager | |
| @contextmanager | |
| def signal_timer(mili): |
This file contains hidden or 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
| import signal | |
| class TimerException(Exception): pass | |
| def timeout(signum, frame): | |
| print "signal handler exception", signum | |
| print frame | |
| raise TimerException(frame) | |
| signal.signal(signal.SIGALRM, timeout) |
This file contains hidden or 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
| import functools | |
| class generatorfunction(object): | |
| """ | |
| Apparently you can't monkeypatch generator objects for some reason. | |
| Lets go ahead and proxy them instead to add __call__. | |
| """ | |
| def __init__(self, generator): | |
| self.delegate = generator |
This file contains hidden or 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
| class CachingInterface (object): | |
| def __init__(self): | |
| "To be overridden by the sub-class." | |
| raise Exception("not implemented") | |
| def store(key, value, type='post'): | |
| """ | |
| Store a key/value pair in the cache. Returns a Deferred. | |
NewerOlder