stop doesn't really stop the rocket server
Bug #1205891 reported by
gbin
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Rocket Web Server |
New
|
Undecided
|
Unassigned |
Bug Description
See the minimal reproduction code here :
https:/
Basically the listening socket is still here long after stop is called.
As you give the host / port to the start method and it starts listening, you kind of expect stop to revert this.
To post a comment you must log in.
I propose this patch to force the server to quit :
diff --git a/rocket/ listener. py b/rocket/ listener. py listener. py listener. py
index 7b54bea..157663b 100644
--- a/rocket/
+++ b/rocket/
@@ -113,40 +113,44 @@ class Listener(Thread):
# secure socket. We don't do anything because it will be detected
# by Worker and dealt with appropriately.
pass
-
+
return sock
def start(self):
self. err_log. warning( 'Listener started when not ready.') isAlive( ):
self. err_log. warning( 'Listener already running.')
self. thread = Thread( target= self.listen, name="Port" + str(self.port))
self. thread. start() shutdown( socket. SHUT_RDWR) isAlive( )
if not self.ready:
return
-
+
if self.thread is not None and self.thread.
return
-
+
-
+
-
+
+ def stop(self):
+ self.ready = False
+ self.listener.
+
def isAlive(self):
if self.thread is None:
return False
-
+
return self.thread.
def join(self):
self. thread. join()
self. thread = None
self. err_log. debug(' Entering main loop.')
self. interface[ 1],
self. secure) )
if self.thread is None:
return
-
+
self.ready = False
-
+
-
+
del self.thread
self.ready = True
-
+
def listen(self):
if __debug__:
@@ -161,15 +165,13 @@ class Listener(Thread):
- except socket.timeout: STOP_CHECK_ INTERVAL
if __debug__:
self. err_log. debug(' Listener exiting.')
return
else: log.error( str(traceback. format_ exc()))
continue log.error( str(traceback. format_ exc()))
+ except:
# socket.timeout will be raised every THREAD_
# seconds. When that happens, we check if it's time to die.
-
if not self.ready:
+ self.err_
- except:
- self.err_
diff --git a/rocket/main.py b/rocket/main.py
index b8d7a01..baf4499 100644
--- a/rocket/main.py
+++ b/rocket/main.py
@@ -159,7 +159,7 @@ class Rocket(object):
try:
# Stop listeners
for l in self.listeners:
- l.ready = False
+ l.stop()
# Encourage a context switch
time. sleep(0. 01)