Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt4 import QtGui, QtCore
- import sys, socketserver
- thd, thd2, thd3 = None, None, None
- class T(QtCore.QThread):
- def __init__(self, f):
- super().__init__()
- self.f = f
- def run(self):
- print("running", self.f)
- self.f()
- def thd_fin():
- print("Fin.")
- def thd_fin3():
- print("Fin3.")
- class TCPServer(socketserver.TCPServer):
- allow_reuse_address = True
- class Handler(socketserver.BaseRequestHandler):
- def handle(self):
- global thd3
- thd3 = T(lambda: None)
- thd3.finished.connect(thd_fin3)
- thd3.start()
- class Form(QtGui.QWidget):
- def __init__(self):
- super().__init__()
- global thd, thd2
- thd = T(lambda: None)
- thd.finished.connect(thd_fin)
- thd.start()
- self.server = TCPServer(("localhost", 50002), Handler)
- global thd2
- thd2 = T(self.server.serve_forever)
- thd2.start()
- app = QtGui.QApplication(sys.argv)
- form = Form()
- form.show()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment