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

OSError: [WinError 10038] An operation was attempted on something that is not a socket #166

Open
tgg-bartek opened this issue May 7, 2024 · 0 comments

Comments

@tgg-bartek
Copy link

Describe the bug
Your very own code snippet fails when run in a loop.

import asyncio

from proxybroker import Broker


async def save(proxies, filename):
    """Save proxies to a file."""
    with open(filename, 'w') as f:
        while True:
            proxy = await proxies.get()
            if proxy is None:
                break
            proto = 'https' if 'HTTPS' in proxy.types else 'http'
            row = '%s://%s:%d\n' % (proto, proxy.host, proxy.port)
            f.write(row)


def main():
    proxies = asyncio.Queue()
    broker = Broker(proxies)
    tasks = asyncio.gather(
        broker.find(types=['HTTP', 'HTTPS'], limit=10),
        save(proxies, filename='proxies.txt'),
    )
    loop = asyncio.get_event_loop()
    loop.run_until_complete(tasks)


if __name__ == '__main__':
    for _ in range(5):
        main()

Raises

Traceback (most recent call last):
File "C:\Python\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
self.run_forever()
File "C:\Python\Python38\lib\asyncio\base_events.py", line 570, in run_forever
self._run_once()
File "C:\Python\Python38\lib\asyncio\base_events.py", line 1823, in _run_once
event_list = self._selector.select(timeout)
File "C:\Python\Python38\lib\selectors.py", line 323, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "C:\Python\Python38\lib\selectors.py", line 314, in _select
r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket

Im on Windows 7.

Adding broker.stop() does not solve it.

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

1 participant