ProxyBroker icon indicating copy to clipboard operation
ProxyBroker copied to clipboard

DeprecationWarning after setting new event loop

Open aleksul opened this issue 5 years ago • 2 comments

On python 3.6.10 after setting new event loop with asyncio.set_event_loop(asyncio.new_event_loop()) Got ~/venv-python36/lib/python3.6/site-packages/proxybroker/providers.py:78: DeprecationWarning: The object should be created from async function headers=get_headers(), cookies=self._cookies, loop=self._loop ~/venv-python36/lib/python3.6/site-packages/aiohttp/connector.py:731: DeprecationWarning: The object should be created from async function loop=loop) ~/venv-python36/lib/python3.6/site-packages/aiohttp/cookiejar.py:55: DeprecationWarning: The object should be created from async function super().__init__(loop=loop) However, I can get the list of proxies with broker.find() but after the program stops

aleksul avatar Apr 23 '20 14:04 aleksul

Try to import proxybroker after setting a new event loop.

I've stumbled upon a similar bug, I tried to run proxybroker in a Celery task (running with --pool=prefork) on macOS.

The solution is to create a new event loop, and import proxybroker after event loop initialization because proxybroker creates a built-in list of Provider objects with default event loop.

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
from proxybroker import Broker

# ...all your code...

the-owl avatar May 23 '20 14:05 the-owl

Try to import proxybroker after setting a new event loop.

I've stumbled upon a similar bug, I tried to run proxybroker in a Celery task (running with --pool=prefork) on macOS.

The solution is to create a new event loop, and import proxybroker after event loop initialization because proxybroker creates a built-in list of Provider objects with default event loop.

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
from proxybroker import Broker

# ...all your code...

Wow. Will try as soon as possible. I might be wrong but it seems to be not python-like, isn't it?

aleksul avatar May 26 '20 20:05 aleksul