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

Support Python 3.10, Revise the scenario on event loop #89

Open
afunTW opened this issue Aug 22, 2022 · 8 comments
Open

Support Python 3.10, Revise the scenario on event loop #89

afunTW opened this issue Aug 22, 2022 · 8 comments

Comments

@afunTW
Copy link
Collaborator

afunTW commented Aug 22, 2022

Summary

Due to another Python 3.10 deprecated warning, this will happen in the near future.
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop

get_event_loop checked the event loop and set a new one if not exist, but this will be an alias of get_running_loop. We need the error handling on this.

@bluet bluet changed the title Revise the scenario on event loop Support Python 3.10, Revise the scenario on event loop Aug 22, 2022
@airone01
Copy link

airone01 commented Sep 1, 2022

For those new to python like me, you can follow this stack question to install an older version of python. Just don't symlink your version or uninstall python3. I tried.

@ziloka
Copy link

ziloka commented Sep 1, 2022

image
I'm not sure what you're using. Maybe you're using the old proxybroker. I don't think pypi package for proxybroker2 has come out yet? In the meanwhile you can install it using the master branch

pip install git+https://github.com/bluet/proxybroker2

Just make sure you have git installed.

@afunTW
Copy link
Collaborator Author

afunTW commented Sep 2, 2022

Hi @airone01

As @ziloka said, we are not on the public PyPI server since this is a fork project. So it might not be related to the Python version only.

Besides that, as a Python developer, I will recommend you to use some virtual environment tools (e.g. Poetry) and a python version manager (e.g. pyenv). The isolation is important when it comes to contributing the open source in many different versions and dependencies.

@airone01
Copy link

airone01 commented Sep 2, 2022

Yeah just realised pyenv is a thing. I've been trying to install python 3.9.13 since a while now without success.
By the way does proxybroker2 use libssl1.0 ? I'm seeing a lot of certificates error when i use the docker image

@ziloka
Copy link

ziloka commented Sep 8, 2022

Give some information about your python installation along with some screenshots for more information and maybe I can reproduce and find a solution

@airone01
Copy link

airone01 commented Sep 8, 2022

I'm getting these when using the docker image, not when compiling

@DiazOlveraCo
Copy link

I'm confused I'm new to python and I'm making chatgpt write all the code

Do I have to use proxybroker2 in the code instead of proxybroker

import asyncio
from proxybroker import Broker

async def show(proxies):
while True:
proxy = await proxies.get()
if proxy is None: break
if proxy.geo and proxy.geo.region == 'CA': # filter proxies by region (California)
print('Found proxy in %s, %s: %s' % (proxy.geo.city, proxy.geo.region, proxy.host))

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

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


TypeError Traceback (most recent call last)
Cell In[5], line 13
11 proxies = asyncio.Queue()
12 loop = asyncio.get_event_loop()
---> 13 broker = Broker(proxies, loop=loop) # pass event loop to Broker constructor
14 tasks = asyncio.gather(
15 broker.find(types=['HTTP', 'HTTPS'], limit=10),
16 show(proxies))
18 loop.run_until_complete(tasks)

File c:\Users\Nesto\AppData\Local\Programs\Python\Python311\Lib\site-packages\proxybroker\api.py:97, in Broker.init(self, queue, timeout, max_conn, max_tries, judges, providers, verify_ssl, loop, **kwargs)
94 max_tries = attempts_conn
96 # The maximum number of concurrent checking proxies
---> 97 self._on_check = asyncio.Queue(maxsize=max_conn, loop=self._loop)
98 self._max_tries = max_tries
99 self._judges = judges

TypeError: Queue.init() got an unexpected keyword argument 'loop'

@ziloka
Copy link

ziloka commented Feb 20, 2023

@DiazOlveraCo

I'm confused I'm new to python and I'm making chatgpt write all the code

Please look at the examples folder for examples

Do I have to use proxybroker2 in the code instead of proxybroker
Yes?

Please ensure that you have properly installed this project.
Installing this dependency via poetry can be done by executing this command

poetry add git+https://github.com/bluet/proxybroker2

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

4 participants