Skip to content
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

set_wakeup_fd only works in main thread of the main interpreter #186

Open
zzm88 opened this issue Aug 8, 2021 · 1 comment
Open

set_wakeup_fd only works in main thread of the main interpreter #186

zzm88 opened this issue Aug 8, 2021 · 1 comment

Comments

@zzm88
Copy link

zzm88 commented Aug 8, 2021

I tried to use django-apscheduler to add a job, which simply calls the function in test_proxybroker.py.
There is no problem to run test_proxybroker.py and got proxies returned.
But I got this error

set_wakeup_fd only works in main thread of the main interpreter

when I run the django-apscheduler command.

#test_proxybroker.py
import asyncio
from proxybroker import Broker

# https://proxybroker.readthedocs.io/en/latest/examples.html
def broke():
    async def show(proxies):
        while True:
            proxy = await proxies.get()
            if proxy is None: break
            print('Found proxy: %s' % proxy)
    try:
        loop = asyncio.get_event_loop()
    except:
        new_loop = asyncio.new_event_loop()
        asyncio.set_event_loop(new_loop)
        loop = asyncio.get_event_loop()

    proxies = asyncio.Queue()
    broker = Broker(proxies)
    tasks = asyncio.gather(
        broker.find(types=['HTTP', 'HTTPS'], limit=10),
        show(proxies))



    loop.run_until_complete(tasks)


#runapscheduler.py. (the django command file)
...
def test_job():
    try:
        broke()
    except:
        pass
...
@bluet
Copy link

bluet commented Aug 20, 2022

As this project is not maintained by the original developer, we've forked ProxyBroker and continued maintaining the proxybroker2 project since 2020.

If anyone's interested, please join. We need more volunteers. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants