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

Threading timing issue #1054

Closed
SmileyChris opened this issue Mar 4, 2015 · 8 comments
Closed

Threading timing issue #1054

SmileyChris opened this issue Mar 4, 2015 · 8 comments

Comments

@SmileyChris
Copy link
Contributor

Installed electrum 2.0 on my laptop and fired it up, noticing the following exception being raised. Wouldn't synchronise and trying to bring up the network dialog caused the app to lock up.

Exception in thread Thread-13:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/chris/.virtualenvs/electrum/local/lib/python2.7/site-packages/electrum/network.py", line 362, in process_requests_thread
    self.process_request(request)
  File "/home/chris/.virtualenvs/electrum/local/lib/python2.7/site-packages/electrum/network.py", line 391, in process_request
    self.interface.send_request(request)
  File "/home/chris/.virtualenvs/electrum/local/lib/python2.7/site-packages/electrum/interface.py", line 290, in send_request
    self.pipe.send(r)
AttributeError: 'TcpInterface' object has no attribute 'pipe'

As a totally hacky test (and it turned out to work) in network.py, I just added a small sleep in to ensure the network threads had time to initialize. I'm sure there's a cleaner way so I'm not going to pull request this hack 😸

    def process_requests_thread(self):
        time.sleep(.1)
@ecdsa
Copy link
Member

ecdsa commented Mar 4, 2015

is there a way to trigger that bug reliably?

@SmileyChris
Copy link
Contributor Author

Not that I can think of - timing issues are a pain to debug :-/

It triggers every time on my laptop, but on my desktop it never does.
Both installed on Ubuntu 14.10 in the same way.

@ecdsa
Copy link
Member

ecdsa commented Mar 4, 2015

yeah there should be a way to insert a sleep() that triggers it

@ecdsa
Copy link
Member

ecdsa commented Mar 4, 2015

can you try that please:

--- a/lib/network.py
+++ b/lib/network.py
@@ -355,6 +355,9 @@ class Network(threading.Thread):

     def process_requests_thread(self):
         while self.is_running():
+            if not self.is_connected():
+                time.sleep(0.1)
+                continue
             try:
                 request = self.requests_queue.get(timeout=0.1)
             except Queue.Empty:

@SmileyChris
Copy link
Contributor Author

Ok, checked that out -- no error there but now I can't reproduce the error in the first place.

Without understanding the code at all, I'm wondering if it was only an issue if there's a request in the queue right off the bat. In which case, I guess your code would fix it... :)

@ecdsa
Copy link
Member

ecdsa commented Mar 5, 2015

well, unfortunately that patch breaks other things..

@SmileyChris
Copy link
Contributor Author

Well the issue resolved itself for me, but probably only because I worked
around the issue. I'll let you have a ponder as to whether there's an easy
solution or if this is just an outlier bug. Thanks for electrum, you rock.

On Thu, 5 Mar 2015 11:34 pm ThomasV notifications@github.com wrote:

well, unfortunately that patch breaks other things..


Reply to this email directly or view it on GitHub
#1054 (comment).

@ecdsa
Copy link
Member

ecdsa commented Mar 8, 2015

fixed in 73d8ba2

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

2 participants