test_service.py 541 B

12345678910111213141516171819202122232425
  1. from modelverse import *
  2. init()
  3. login("test_service", "my_password")
  4. def fibonacci_service(port):
  5. def fibonacci(value):
  6. if value <= 2:
  7. return 1
  8. else:
  9. return fibonacci(value - 1) + fibonacci(value - 2)
  10. service_set(port, fibonacci(service_get(port)))
  11. service_register("fibonacci", fibonacci_service)
  12. print("Registered")
  13. while raw_input() != "STOP":
  14. # Stay active, as we shouldn't exit while the service is running!
  15. pass
  16. print("Stopping")
  17. service_stop()
  18. print("Service halted")