Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Fix task API creation flow #4755

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions golem/task/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from golem.core import golem_async
from golem.core import common
from golem.core import simpleserializer
from golem.core.deferred import DeferredSeq
from golem.core.deferred import DeferredSeq, deferred_from_future
from golem.ethereum import exceptions as eth_exceptions
from golem.model import Actor
from golem.resource import resource
Expand Down Expand Up @@ -576,15 +576,13 @@ def create_task_api_task(self, task_params: dict, golem_params: dict):
@defer.inlineCallbacks
def init_task():
try:
self.requested_task_manager.init_task(task_id)
yield deferred_from_future(
self.requested_task_manager.init_task(task_id))
except Exception:
self.client.funds_locker.remove_task(task_id)
raise
else:
self.requested_task_manager.start_task(task_id)
# Dummy yield to make this function work with inlineCallbacks.
# To be removed when there are other yeilds in this function.
yield defer.Deferred()

# Do not yield, this is a fire and forget deferred as it may take long
# time to complete and shouldn't block the RPC call.
Expand Down
1 change: 0 additions & 1 deletion tests/golem/task/test_rpc_task_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def test_success(self):
)

self.requested_task_manager.init_task.assert_called_once_with(task_id)
self.requested_task_manager.start_task.assert_called_once_with(task_id)

def test_failed_init(self):
self.requested_task_manager.init_task.side_effect = Exception
Expand Down