Python-ELMO is a Python library which offers an encapsulation of the binary tool ELMO, in order to manipulate it easily in Python and SageMath script.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

servicethread.py 993B

il y a 4 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import threading
  2. from protocol import Protocol, ClosureException
  3. class ServiceThread(threading.Thread):
  4. def run(self):
  5. self.execute()
  6. def execute(self):
  7. # Method where the service runs
  8. pass
  9. class OneShotServiceThread(ServiceThread):
  10. def __init__(self, ip, port, clientsocket):
  11. threading.Thread.__init__(self)
  12. self.ip = ip
  13. self.port = port
  14. self.clientsocket = clientsocket
  15. self.protocol = Protocol(clientsocket)
  16. def run(self):
  17. try:
  18. self.execute()
  19. except ClosureException:
  20. return
  21. def execute(self):
  22. # Method where the service runs
  23. pass
  24. class PermanentServiceThread(ServiceThread):
  25. def __init__(self):
  26. threading.Thread.__init__(self)
  27. self._is_running = True
  28. def is_running(self):
  29. return self._is_running
  30. def stop(self):
  31. self._is_running = False