ad-m / python-anticaptcha

Client library for solve captchas with Anticaptcha.com support.
http://python-anticaptcha.readthedocs.io/en/latest/
MIT License
219 stars 51 forks source link

Setting a timeout #66

Closed riccardolunardi closed 4 years ago

riccardolunardi commented 4 years ago

Hi! I was testing some code that uses this library and sometimes the task never get completed, so the code get stuck on that point without returning any error. Is there a way to set a timeout to the task on your code? I don't need you to implement this, but I would like to know how to do it myself, since (at least for me) it's not clear how to do it. Thanks :)

ad-m commented 4 years ago

Do you use createTask or createTaskSmee? Timeout is already implemented when you call ".join()".

riccardolunardi commented 4 years ago

createTaskSmee. And yes, I can use the join. Sorry for the silly question and thanks for the repo :)

ad-m commented 4 years ago

This issue is similiar to #50 .

Thank you for the information about issues in createTaskSmee.

It looks like more offen than I expect there is issues in createTaskSmee which uses free smee.io service, which does not guarantee any level of SLA. I will introduce any time limit for reading data from Smee to avoid stuck of script.

I will consider launching my own service of this kind & hope to provide better level of operation.

In mean time, could you use createTask (using callback or through polling)? It's should be free from any issues like that. Example is available https://github.com/ad-m/python-anticaptcha/blob/master/examples/text.py . createTask and createTaskSmee is interchangeable.

riccardolunardi commented 4 years ago

I'll try as soon as I can :)

namename-123 commented 4 years ago

Can we set our custom timeout?

ad-m commented 4 years ago

@virg1n , yes, you need upgrade to 0.6.0. In version `0.6.0 proper timeout managed was added.

Added custom timeout for createTaskSmee. Use as client.createTaskSmee(task, timeout=5*60). Default timeout is 5 minutes.

Default 5 seconds timeout apply to all API request.