Getting the service instance

Getting an instance of a running service as code

If the a Service instance is needed outside the Service class itself, it can be acquired with tomodachi.get_service. If multiple Service instances exist within the same event loop, the name of the Service can be used to get the correct one.

import tomodachi

# Get the instance of the active Service.
service = tomodachi.get_service()

# Get the instance of the Service by service name.
service = tomodachi.get_service(service_name)