Merge ~nteodosio/software-properties:bionic-threading into software-properties:ubuntu/bionic

Proposed by Nathan Teodosio
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 48c7ce0ea95fa73ea4151516bb307178d934b2df
Merged at revision: 48c7ce0ea95fa73ea4151516bb307178d934b2df
Proposed branch: ~nteodosio/software-properties:bionic-threading
Merge into: software-properties:ubuntu/bionic
Diff against target: 24 lines (+4/-2)
1 file modified
softwareproperties/gtk/DialogUaAttach.py (+4/-2)
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+437434@code.launchpad.net

Description of the change

Having the internet disconnected after a PIN was already retrieved leads to, after some seconds,

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/DialogUaAttach.py", line 196, in net_status_changed
    self.poll = GLib.Thread.new("poll", self.poll_for_magic_token)
AttributeError: type object 'Thread' has no attribute 'new'

Additionally, the lack of self.poll assignment causes the PIN to change every single time the user clicks the PIN radio.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/softwareproperties/gtk/DialogUaAttach.py b/softwareproperties/gtk/DialogUaAttach.py
2index 7dd32dc..6fcfc92 100644
3--- a/softwareproperties/gtk/DialogUaAttach.py
4+++ b/softwareproperties/gtk/DialogUaAttach.py
5@@ -173,7 +173,8 @@ class DialogUaAttach:
6 print("Error retrieving magic token: ", e)
7 return
8 self.update_state()
9- threading.Thread(target=self.poll_for_magic_token, daemon=True).start()
10+ self.poll = threading.Thread(target=self.poll_for_magic_token, daemon=True)
11+ self.poll.start()
12
13 def on_radio_toggled(self, button):
14 self.update_state()
15@@ -193,7 +194,8 @@ class DialogUaAttach:
16 self.start_magic_attach()
17 elif self.poll == None:
18 # wait() timed out without internet; Restart polling.
19- self.poll = GLib.Thread.new("poll", self.poll_for_magic_token)
20+ self.poll = threading.Thread(target=self.poll_for_magic_token, daemon=True)
21+ self.poll.start()
22
23 def finish(self):
24 self.dialog.response(Gtk.ResponseType.OK)

Subscribers

People subscribed via source and target branches