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.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

servicethread.py 993B

  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