Git Product home page Git Product logo

Comments (9)

QIN2DIM avatar QIN2DIM commented on July 23, 2024 1
def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()
    job_thread.join()

run_threaded(job_func)

from hcaptcha-challenger.

QIN2DIM avatar QIN2DIM commented on July 23, 2024 1
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")
    )

from hcaptcha-challenger.

GoldDust69 avatar GoldDust69 commented on July 23, 2024

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.

from hcaptcha-challenger.

QIN2DIM avatar QIN2DIM commented on July 23, 2024

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

?👀

from hcaptcha-challenger.

GoldDust69 avatar GoldDust69 commented on July 23, 2024

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 :)

from hcaptcha-challenger.

GoldDust69 avatar GoldDust69 commented on July 23, 2024
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.

from hcaptcha-challenger.

QIN2DIM avatar QIN2DIM commented on July 23, 2024

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

from hcaptcha-challenger.

GoldDust69 avatar GoldDust69 commented on July 23, 2024

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

from hcaptcha-challenger.

QIN2DIM avatar QIN2DIM commented on July 23, 2024

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

from hcaptcha-challenger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.