Skip to content

Some edits (Python 2.6 compat., no websocket by default, some debugging) - #10

Open
Elektordi wants to merge 4 commits into
OliverF:masterfrom
Elektordi:master
Open

Some edits (Python 2.6 compat., no websocket by default, some debugging)#10
Elektordi wants to merge 4 commits into
OliverF:masterfrom
Elektordi:master

Conversation

@Elektordi

Copy link
Copy Markdown

No description provided.

@OliverF

OliverF commented Jul 29, 2016

Copy link
Copy Markdown
Owner

Great, thanks for this. I'll have a quick look now and do a quick test over the weekend.

@Elektordi

Copy link
Copy Markdown
Author

Hello! Did you had any time to review this?

@Silex

Silex commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

I think "Prevent exception on quit" 986760e is the wrong fix.

IMHO 70501e9 from #13 is the right one.

The other commits looks fine tho, I'd just drop the last one.

@Elektordi

Copy link
Copy Markdown
Author

This seems to be different problems. In 986760e, I'm fixing a bug I think I added in previous commit:
Since you can disable the sockets, there will be exception if at the end you try to close a socket that was disabled on startup.

@Silex

Silex commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

Well, ok for the requestHandler variable, but for the broadcast variable it is a mistake because it is always present. Also your fix does not take care of the quitsock. The diff should be like this:

diff --git a/relay.py b/relay.py
index e2285b3..3014132 100644
--- a/relay.py
+++ b/relay.py
@@ -24,8 +24,10 @@
 # Close threads gracefully
 #
 def quit():
	broadcast.kill = True
-	requestHandler.kill = True

- 	quitsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- 	quitsock.connect(("127.0.0.1", options.port))
- 	quitsock.close()
+	if requestHandler:
+		requestHandler.kill = True
+  		quitsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ 	 	quitsock.connect(("127.0.0.1", options.port))
+ 	 	quitsock.close()
 	sys.exit(1)
@@ -54,6 +56,9 @@ def quit():
 		logging.error("Port must be numeric")
 		op.print_help()
 		sys.exit(1)
+		
+	requestHandler = None
 
 	Status()
 	statusThread = threading.Thread(target=Status._instance.run)

Then my commit fixes the broadcast --> broadcaster typo.

@Silex

Silex commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

To be honest the whole quit() code is dubious.

Instead of all these foo.kill = True, it'd be code like requestHandler.acceptsock.close(), possibly wrapped in some requestHandler.shutdown() method.

@Silex

Silex commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

Here is what I have in mind as a refactoring of the shutdown process: Silex@217904d

@OliverF

OliverF commented Dec 12, 2016

Copy link
Copy Markdown
Owner

Sorry @Elektordi, I haven't forgotten about this, I've just been very busy lately!

@Silex good catch regarding quitsock. I think you're right, the whole quit process needs re-thinking. Perhaps we could open a new PR for your proposed changes and discuss there?

@Silex

Silex commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

A'ight 👍

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

Successfully merging this pull request may close these issues.

3 participants