Sat 10 May 2003 01:33:01 PM UTC, original submission:
On startup, I sometimes have the "couldnt find any peers" window popping up, even though it does find some peers, which are displayed on the blue thingy..
This happens to me at home, since I have a DSL connection that induces some latency. Here is why it occurs:
During the initialization of app.node, peers are greeted like this:
self.found_peers = self.greet_known_peers()
In circle.py (run_main routine), a "waiter" waits for greet_known_peers to return:
if not no_connect:
def waiter(node):
if hasattr(node, 'found_peers'):
utility.threadnice_mainquit()
return gtk.FALSE
return gtk.TRUE
utility.schedule_mainthread(250.0, waiter, self.node)
utility.threadnice_mainloop()
this means wait 250 ms, and then wait until
greet_known_peers is done. after that, the
routine checks for peers:
any = (len(self.node.peers) <> 0)
The problem is that greet_known_peers returns immediately.
So there is no point using this "waiter"...
In fact, greet_known_peers launches a number of threads,
and then it returns. These threads do the job of calling the peers, and update node.peers.
So greet_known_peers returns before these threads have updated node.peers. And if it takes more than 250ms to contact the first peer, then circle becomes confused
and says that it could not find any peer.
workaround: I replaced 250ms by 1000ms on my system,
given that my connection has more latency than a T1.
fix: I suggest two things:
1. to remove the "waiter", because it is not doing anything useful. I guess it is a fossil of an ancient time, where greet_known_peers was not launching threads.
2. The "couldnt find any peers" window is useful, we should keep it. But it should show up later if the connection is slow. Maybe circle could maintain an average of how long it takes to connect, and complain only if it takes more than 10 times this average time. Initially, this average time would be set to a high value.
Feedback welcome...
|