Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default implementation of Service.run() yields None which causes an error #443

Closed
azawlocki opened this issue Jun 8, 2021 · 0 comments
Closed
Assignees
Labels
beta.2.patch.1 bug Something isn't working

Comments

@azawlocki
Copy link
Contributor

Consider the following script:

import ...  # omitted

class SimpleService(Service):
    @staticmethod
    async def get_payload():
        # this could be any valid image 
        return await vm.repo(
            image_hash="8b11df59f84358d47fc6776d0bb7290b0054c15ded2d6f54cf634488",
            min_mem_gib=0.5,
            min_storage_gib=2.0,
        )
    # start(), run() and shutdown() are inherited from Service

 async def main():
     async with Golem(budget=1.0) as golem:
         cluster = await golem.run_service(SimpleService)
         while True:
             if cluster.instances:
                 print(f"Service is {cluster.instances[0].state.value}")
             await asyncio.sleep(5)

enable_default_logger()

loop = asyncio.get_event_loop()
task = loop.create_task(main())
loop.run_until_complete(task)

It's output shows that the default Service.run() method causes an error since it yields None:

[2021-06-08 23:25:39,711 INFO yapapi.summary] Received proposals from 1 provider so far
[2021-06-08 23:25:39,715 INFO yapapi.summary] Received proposals from 2 providers so far
[2021-06-08 23:25:40,369 INFO yapapi.summary] Agreement proposed to provider 'provider-1'
[2021-06-08 23:25:40,427 INFO yapapi.summary] Agreement confirmed by provider 'provider-1'
[2021-06-08 23:25:41,189 INFO yapapi.services] <SimpleService: e4aaadd900bb42959323cf2ac32866bc> commissioned
[2021-06-08 23:25:41,191 INFO yapapi.summary] Task started on provider 'provider-1', task data: Service: SimpleService
Service is starting
Service is running
Service is running
[2021-06-08 23:25:54,819 WARNING yapapi.summary] Worker for provider 'provider-1' failed; reason: 'NoneType' object has no attribute 'timeout'
[2021-06-08 23:25:54,839 INFO yapapi.summary] Terminated agreement with provider-1
[2021-06-08 23:25:56,846 INFO yapapi.summary] Accepted invoice from 'provider-1', amount: 0.004154389926666667
Service is running
Service is running
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta.2.patch.1 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants