Closed qstokkink closed 2 months ago
Strange, counts on my machine seem fine (Win10 + Python 3.9).
Seemingly, setting "statistics"
to false
in the configuration solves this. This might be a coincidence, I'll run a few more tests.
EDIT: Alright, I'm convinced, the statistics
setting really seems to be the culprit (but why?).
😮 this might actually be an IPv8 bug.
If I remove StatisticsEndpoint.__getattribute__
and implement all the Endpoint
methods like a normal subclass, everything works UPDATE: it works more often (perhaps some sort of threading issue??).
I thought the "interface": "UDPIPv6"
could maybe play a part in this. I removed that but this still happens.
Ok, this took a turn for the weird.
I added a print statement to UDPEndpoint.datagram_received
. Then I ran Tribler with and without statistics enabled.
When enabling statistics. datagram_received
gets called a few hundred times and then never gets called again. The result is that a few peers come in and then get dropped (correctly) as we never receive another message.
Without enabling statistics, datagram_received
never gets called but I get a lot of peers.
Just tested on Ubuntu 22.04 and this does not happen there. Only on Windows apparently.
Regarding "datagram_received
never gets called but I get a lot of peers": this is because I installed the rust extension. That should be fine.
This might be https://bugs.python.org/issue44743
The bug manifests with all combinations: SelectorEventLoop and ProactorEventLoop, python 3.9 and 3.10, on Windows 10.
I just brought my consistently failing laptop from the office to my home and now it consistently works without any issues. Same machine and the same code.
I added a callback to the UDPEndpoint
class.
def error_received(self, exc):
print("!!! ERROR RECEIVED !!!", exc)
Over a run, this outputted three times:
!!! ERROR RECEIVED !!! [WinError 1214] The format of the specified network name is invalid
!!! ERROR RECEIVED !!! [WinError 1234] No service is operating at the destination network endpoint on the remote system
!!! ERROR RECEIVED !!! [WinError 1231] The network location cannot be reached. For information about network troubleshooting, see Windows Help
After the third message, peers started dropping.
Wait, hold on, I just discovered that my DatagramTransport
is a _ProactorDatagramTransport
. This may be a case of not setting the selector event loop correctly.
Confirmed:
asyncio.set_event_loop(asyncio.SelectorEventLoop())
asyncio.run(main())
Gives me a <ProactorEventLoop running=True closed=False debug=False>
.
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
Gives me a <_WindowsSelectorEventLoop running=True closed=False debug=False>
.
Run 1:
Run 2:
My peer counts go up after starting Tribler and then quickly go down to near zero.