8000 fix: close already started Peas when one of them fail to start by JoanFM · Pull Request #1863 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: close already started Peas when one of them fail to start #1863

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

Merged
merged 1 commit into from
Feb 4, 2021
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
8000
Diff view
10 changes: 6 additions & 4 deletions jina/peapods/pods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ def start(self) -> 'BasePod':
which is inherited from :class:`jina.peapods.peas.BasePea`
"""
# start head and tail

for _args in self.all_args:
self._enter_pea(BasePea(_args))

try:
for _args in self.all_args:
self._enter_pea(BasePea(_args))
except:
self.close()
raise
return self

def _enter_pea(self, pea: 'BasePea') -> None:
Expand Down
4 changes: 1 addition & 3 deletions tests/daemon/unit/stores/test_flowstore.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from pathlib import Path

from fastapi import UploadFile

from daemon.stores import FlowStore
from jina.flow import Flow

Expand All @@ -22,7 +20,7 @@ def test_flow_store():
assert len(store) == 1
assert flow_id in store
assert isinstance(store[flow_id]['object'], Flow)
del store[flow_id]
store.delete(flow_id)
assert flow_id not in store
assert not store

Empty file.
22 changes: 22 additions & 0 deletions tests/integration/issues/github_1861/test_pea_closing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from jina.executors.encoders import BaseEncoder
from jina.flow import Flow


class ExceptionExecutor(BaseEncoder):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.name = 'exception-executor'

def post_init(self):
raise Exception


@pytest.mark.timeout(10)
def test_pea_closing():
with pytest.raises(Exception):
with Flow().add(uses='!ExceptionExecutor', parallel=3) as f:
pod1 = f._pod_nodes['pod0']
assert len(pod1.peas) == 0
0