Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

feat(add): pypi release #16

Closed
QIN2DIM opened this issue Mar 9, 2022 · 9 comments
Closed

feat(add): pypi release #16

QIN2DIM opened this issue Mar 9, 2022 · 9 comments
Labels
feature 新特性或新需求

Comments

@QIN2DIM
Copy link
Owner

QIN2DIM commented Mar 9, 2022

We will release the heterogeneous scaffolding in v1.0 and upload the project package to pypi platform, then players can use pip to install and use hcaptcha-challenger.

But before that, we will absorb as many suggestions from players as possible, and we will also re-standardize the model of the scaffolding interface so that it can be called in various suitable occasions.

@QIN2DIM QIN2DIM added the feature 新特性或新需求 label Mar 9, 2022
@GoldDust69
Copy link

Hello, I just wondered if you had any plans to enable multi threading for this. For my custom use case, it seems that the "Image Downloader" makes this incompatible due to the asyncio loop structure. Unfortunately, I do not have the skills to modify this myself and was left wondering if this could be a useful feature for other people too.

@QIN2DIM
Copy link
Owner Author

QIN2DIM commented Mar 14, 2022

For my custom use case, it seems that the "Image Downloader" makes this incompatible due to the asyncio loop structure.

?👀

@GoldDust69
Copy link

GoldDust69 commented Mar 14, 2022

For my custom use case, it seems that the "Image Downloader" makes this incompatible due to the asyncio loop structure.

?👀

For example, when I try the captcha challenge in a function, such as the following:

def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()
    
run_threaded(job_func)

I receive the following error: "RuntimeError: There is no current event loop in thread 'Thread-2 (job_func)".

I tried the following for ImageDownloader() instead, but it was then not downloading the images:

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(downloader.subvert(workers="fast"))

Apologize for my lack of experience but hopefully you understand :)

@QIN2DIM
Copy link
Owner Author

QIN2DIM commented Mar 14, 2022

def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()
    job_thread.join()

run_threaded(job_func)

@QIN2DIM
Copy link
Owner Author

QIN2DIM commented Mar 14, 2022

if "win" in sys.platform:
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    asyncio.run(ImageDownloader(docker=docker_).subvert(workers="fast"))
else:
    loop = asyncio.get_event_loop()
    loop.run_until_complete(
        ImageDownloader(docker=docker_).subvert(workers="fast")
    )

@GoldDust69
Copy link

def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()
    job_thread.join()

run_threaded(job_func)
if "win" in sys.platform:
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    asyncio.run(ImageDownloader(docker=docker_).subvert(workers="fast"))
else:
    loop = asyncio.get_event_loop()
    loop.run_until_complete(
        ImageDownloader(docker=docker_).subvert(workers="fast")
    )

Thank you so much for taking the time to look at this for me. Your examples work well and I am able to run the function in a thread now. Unfortunately, my goal doesn't seem possible. I was hoping to be able to run multiple threads simultaneously which is why I never used job_thread.join() in my previous code.

@QIN2DIM
Copy link
Owner Author

QIN2DIM commented Mar 15, 2022

我认为有多种方案可以实现你所谓的“异步协同”,此外,使用“协程异步”替代“线程异步”能在这类场景中争取到更多的资源利用率。但为了避免所谓的“滥用”我觉得我不能至少不应该在这种场合将“高性能”的并发方案公之于众。如果你想在你自己的项目中使用 hcaptcha-challenger 你应该知道怎么修改代码。

@GoldDust69
Copy link

我认为有多种方案可以实现你所谓的“异步协同”,此外,使用“协程异步”替代“线程异步”能在这类场景中争取到更多的资源利用率。但为了避免所谓的“滥用”我觉得我不能至少不应该在这种场合将“高性能”的并发方案公之于众。如果你想在你自己的项目中使用 hcaptcha-challenger 你应该知道怎么修改代码。

Thank you for your response. I understand what you mean, unfortunately since this is out of my scope I think I'll have to wait until I have further knowledge of Python. None the less, I appreciate you taking the time to reply.

@QIN2DIM
Copy link
Owner Author

QIN2DIM commented Mar 15, 2022

@GoldDust69 纸上得来终觉浅 绝知此事要躬行

Repository owner locked and limited conversation to collaborators Mar 15, 2022
@QIN2DIM QIN2DIM converted this issue into discussion #18 Mar 15, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
feature 新特性或新需求
Projects
None yet
Development

No branches or pull requests

2 participants