Git Product home page Git Product logo

Comments (12)

ziloka avatar ziloka commented on July 17, 2024

my guess is that you would need to use asyncio.new_event_loop() instead of asyncio.get_event_loop().

But instead of guessing, giving a minimally reproducible example would be more beneficial.

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

I use Windows. I'm using the sample code from the readme:

import asyncio
from proxybroker import Broker

async def show(proxies):
    while True:
        proxy = await proxies.get()
        if proxy is None: break
        print('Found proxy: %s' % proxy)

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

loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)

I get the following error:

PS D:\GitRepo\PythonTest> & d:/GitRepo/PythonTest/.venv/Scripts/python.exe d:/GitRepo/PythonTest/ProxyBroker2.py
Traceback (most recent call last):
  File "d:\GitRepo\PythonTest\ProxyBroker2.py", line 11, in <module>
    broker = Broker(proxies)
             ^^^^^^^^^^^^^^^
  File "D:\GitRepo\PythonTest\.venv\Lib\site-packages\proxybroker\api.py", line 69, in __init__
    self._resolver = Resolver(loop=self._loop)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GitRepo\PythonTest\.venv\Lib\site-packages\proxybroker\resolver.py", line 48, in __init__
    self._resolver = aiodns.DNSResolver(loop=self._loop)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GitRepo\PythonTest\.venv\Lib\site-packages\aiodns\__init__.py", line 55, in __init__
    raise RuntimeError(
RuntimeError: aiodns needs a SelectorEventLoop on Windows. See more: https://github.com/saghul/aiodns/issues/86
PS D:\GitRepo\PythonTest> 

I studied the link (saghul/aiodns#86), but it is not clear how to fix it! I ask for help in fixing the problem!

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

Does this problem have a solution?

from proxybroker2.

ziloka avatar ziloka commented on July 17, 2024

yes
#147 (comment)

it is the only workaround for now

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

What exactly should be done? In the provided answer, it is not clear exactly what actions are needed!

from proxybroker2.

ziloka avatar ziloka commented on July 17, 2024

Please look at this example

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

PS D:\GitRepo\PythonTest> & d:/GitRepo/PythonTest/.venv/Scripts/python.exe d:/GitRepo/PythonTest/ProxyBroker2.py
D:\GitRepo\PythonTest.venv\Lib\site-packages\proxybroker\providers.py:77: DeprecationWarning: The object should be created within an async function
async with aiohttp.ClientSession(
D:\GitRepo\PythonTest.venv\Lib\site-packages\aiohttp\connector.py:776: DeprecationWarning: The object should be created within an async function
super().init(
D:\GitRepo\PythonTest.venv\Lib\site-packages\aiohttp\cookiejar.py:84: DeprecationWarning: The object should be created within an async function
super().init(loop=loop)

from proxybroker2.

ziloka avatar ziloka commented on July 17, 2024

What python version are you running?

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

3.12

from proxybroker2.

ziloka avatar ziloka commented on July 17, 2024

oh i forgot, my pull request haven't been merged yet. PR #147 will fix this.

from proxybroker2.

surgutandrey avatar surgutandrey commented on July 17, 2024

what specific action should be done? Nothing is clear in this discussion

from proxybroker2.

ziloka avatar ziloka commented on July 17, 2024

add the following code after you import asyncio

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

from proxybroker2.

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.