Make some changes to the server to make it easier to close
This commit is contained in:
parent
7fae12acfb
commit
cb850e9ab9
13
nyancat.py
13
nyancat.py
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import SocketServer
|
import SocketServer
|
||||||
|
import threading, os
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from telnetsrvlib import TelnetHandler
|
from telnetsrvlib import TelnetHandler
|
||||||
|
|
||||||
@ -28,5 +29,13 @@ class TNH(TelnetHandler):
|
|||||||
p.kill()
|
p.kill()
|
||||||
return
|
return
|
||||||
|
|
||||||
tns = TNS(("0.0.0.0", 23), TNH)
|
class serverThread(threading.Thread):
|
||||||
tns.serve_forever()
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user