Skip to content

Commit c0adb83

Browse files
committed
fix: attempt to fix saving task hanging issue
1 parent b42ee97 commit c0adb83

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

_ext/python/crawlab/result.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
from queue import Queue
32
from typing import List, Optional, Dict
43

54
from crawlab.client import get_client, Client
@@ -15,12 +14,10 @@ class ResultService:
1514
# internal
1615
c: Client = None
1716
task_stub: TaskServiceStub = None
18-
queue: Queue = Queue()
1917

2018
def __init__(self):
2119
self.c = get_client()
2220
self.task_stub = self.c.task_service_stub
23-
self.task_stub.Subscribe.future(self.yield_msg())
2421

2522
def save_item(self, *items: Dict):
2623
self.save(list(items))
@@ -59,14 +56,7 @@ def _save(self, items: List[Dict]):
5956
code=INSERT_DATA,
6057
data=data,
6158
)
62-
self.enqueue(msg)
63-
64-
def enqueue(self, msg: StreamMessage):
65-
self.queue.put(msg)
66-
67-
def yield_msg(self):
68-
while True:
69-
yield self.queue.get()
59+
self.task_stub.Subscribe(iter([msg]))
7060

7161

7262
RS: Optional[ResultService] = None

_ext/python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='crawlab-sdk',
11-
version='0.6.0-8',
11+
version='0.6.0-9',
1212
packages=find_packages(),
1313
url='https://github.com/crawlab-team/crawlab-sdk',
1414
license='BSD-3-Clause',

0 commit comments

Comments
 (0)