Created
October 31, 2014 19:09
-
-
Save teepark/030c5c5da7b8c7d9be69 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# vim: fileencoding=utf8:et:sw=4:ts=8:sts=4 | |
import os | |
import signal | |
import gevent, gevent.socket as gsock | |
def handler(signum, frame): | |
print "received signal %d" % (signum,) | |
signal.signal(signal.SIGTERM, handler) | |
@gevent.spawn | |
def knock_over(): | |
while 1: | |
gevent.sleep(1) | |
os.kill(os.getpid(), signal.SIGTERM) | |
sock = gsock.socket() | |
sock.bind(("127.0.0.1", 45678)) | |
sock.listen(5) | |
sock.accept() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment