aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Lange <k@dakko.us>2011-11-30 20:31:02 -0600
committerKevin Lange <k@dakko.us>2011-11-30 20:31:02 -0600
commitcb850e9ab9b70f183ef9afbda9952110b3922204 (patch)
treeb5343febc639228b5913b85ace2f43678ed5276e
parent7fae12acfbafdda6642dc834d200f1f0ffbaaa2e (diff)
downloadnyancat-cb850e9ab9b70f183ef9afbda9952110b3922204.tar.gz
Make some changes to the server to make it easier to close
-rwxr-xr-xnyancat.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/nyancat.py b/nyancat.py
index 872cfae..039581c 100755
--- a/nyancat.py
+++ b/nyancat.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import SocketServer
+import threading, os
from subprocess import Popen, PIPE
from telnetsrvlib import TelnetHandler
@@ -28,5 +29,13 @@ class TNH(TelnetHandler):
p.kill()
return
-tns = TNS(("0.0.0.0", 23), TNH)
-tns.serve_forever()
+class serverThread(threading.Thread):
+ def run(self):
+ tns = TNS(("0.0.0.0", 23), TNH)
+ tns.serve_forever()
+
+if __name__ == "__main__":
+ t = serverThread()
+ t.start()
+ raw_input("Let me know when to stop.")
+ os.kill(os.getpid(), 9)