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

[Exception] BlockingIOError: [WinError 10035] A non-blocking socket operation could not be completed immediately #5

Open
Gesugao-san opened this issue Nov 1, 2023 · 0 comments

Comments

@Gesugao-san
Copy link

aiobtdht_readme_example.py:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import asyncio
from aiobtdht import DHT
from aioudp import UDPServer

async def main(loop):
    initial_nodes = [
        ("67.215.246.10", 6881),  # router.bittorrent.com
        ("87.98.162.88", 6881),  # dht.transmissionbt.com
        ("82.221.103.244", 6881)  # router.utorrent.com
    ]

    udp = UDPServer()
    udp.run("0.0.0.0", 12346, loop=loop)

    dht = DHT(int("0x54A10C9B159FC0FBBF6A39029BCEF406904019E0", 16), server=udp, loop=loop)

    print("bootstrap")
    await dht.bootstrap(initial_nodes)
    print("bootstrap done")

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(loop))
    loop.run_forever()
    exit(0)

Output:

C:\censored>python "C:\censored\aiobtdht_readme_example.py"

Initializing DHT
bootstrap
C:\Python311\Lib\site-packages\aiobtdht\dht.py:245: RuntimeWarning: coroutine 'DHT.remote_find_node' was never awaited
  await asyncio.gather(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<UDPServer._recv_periodically() done, defined at C:\Python311\Lib\site-packages\aioudp\server.py:107> exception=NotImplementedError()>
Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\aioudp\server.py", line 57, in _sock_recv
    data, addr = self._sock.recvfrom(self._recv_max_size)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BlockingIOError: [WinError 10035] Операция на незаблокированном сокете не может быть завершена немедленно

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\aioudp\server.py", line 109, in _recv_periodically
    data, addr = await self._sock_recv()
                       ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\aioudp\server.py", line 59, in _sock_recv
    self.loop.add_reader(fd, self._sock_recv, fut, True)
  File "C:\Python311\Lib\asyncio\events.py", line 530, in add_reader
    raise NotImplementedError
NotImplementedError
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<run_every() done, defined at C:\Python311\Lib\site-packages\aiobtdht\utils.py:59> exception=TypeError("gather() got an unexpected keyword argument 'loop'")>
Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\aiobtdht\utils.py", line 64, in run_every
    await r
  File "C:\Python311\Lib\site-packages\aiobtdht\dht.py", line 214, in _refresh_nodes
    await asyncio.gather(
          ^^^^^^^^^^^^^^^
TypeError: gather() got an unexpected keyword argument 'loop'
Traceback (most recent call last):
  File "C:\censored\aiobtdht_readme_example.py", line 26, in <module>
    loop.run_until_complete(main(loop))
  File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\censored\aiobtdht_readme_example.py", line 21, in main
    await dht.bootstrap(initial_nodes)
  File "C:\Python311\Lib\site-packages\aiobtdht\dht.py", line 290, in bootstrap
    responses = await self._group_invoke(lambda peer: self.remote_find_node(peer, self.id), peers)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\aiobtdht\dht.py", line 245, in _group_invoke
    await asyncio.gather(
          ^^^^^^^^^^^^^^^
TypeError: gather() got an unexpected keyword argument 'loop'
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