Skip to content

Commit a6cda4e

Browse files
committed
Update aio_captcha_instrument.py
1 parent 08c829a commit a6cda4e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/python3_capsolver/core/aio_captcha_instrument.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ async def processing_captcha(self) -> dict:
3030

3131
# if task created and already ready - return result
3232
if self.created_task_data.errorId == 0:
33+
if str(self.created_task_data.status).lower() == ResponseStatusEnm.Ready.value:
34+
return self.created_task_data.to_dict()
3335
return (await self.__get_result()).to_dict()
3436
else:
3537
self.created_task_data.status = ResponseStatusEnm.Failed
@@ -72,7 +74,10 @@ async def __get_result(self, url_postfix: str = EndpointPostfixEnm.GET_TASK_RESU
7274
) as resp:
7375
if resp.status in VALID_STATUS_CODES:
7476
result_data = CaptchaResponseSer(**await resp.json())
75-
if result_data.status in (ResponseStatusEnm.Ready, ResponseStatusEnm.Failed):
77+
if result_data.status in (
78+
ResponseStatusEnm.Ready,
79+
ResponseStatusEnm.Failed,
80+
):
7681
# if captcha ready\failed or have unknown status - return exist data
7782
return result_data
7883
else:
@@ -90,10 +95,12 @@ async def __get_result(self, url_postfix: str = EndpointPostfixEnm.GET_TASK_RESU
9095
self.result.errorDescription = self.CAPTCHA_UNSOLVABLE_DESCRIPTION
9196
self.result.taskId = self.created_task_data.taskId
9297
self.result.status = ResponseStatusEnm.Failed
98+
return self.result
9399

94100
@staticmethod
95101
async def send_post_request(
96-
payload: Optional[dict] = None, url_postfix: EndpointPostfixEnm = EndpointPostfixEnm.GET_BALANCE
102+
payload: Optional[dict] = None,
103+
url_postfix: EndpointPostfixEnm = EndpointPostfixEnm.GET_BALANCE,
97104
) -> dict:
98105
"""
99106
Function send ASYNC request to service and wait for result

0 commit comments

Comments
 (0)