All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] prserv/serv: Improve exit handling
@ 2015-01-21 13:53 Richard Purdie
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2015-01-21 13:53 UTC (permalink / raw)
  To: bitbake-devel

Currently, I'm not sure how the prserver managed to shut down cleanly. These
issues may explain some of the hangs people have reported.

This change:

* Ensures the connection acceptance thread monitors self.quit
* We wait for the thread to exit before exitting
* We sync the database when the thread exits
* We do what the comment mentions, timeout after 30s and sync the database
  if needed. Previously, there was no timeout (the 0.5 applies to sockets,
  not the Queue object)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 25eb46a..a7639c8 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
 
         """
         iter_count = 1
-        # With 60 iterations between syncs and a 0.5 second timeout between
-        # iterations, this will sync if dirty every ~30 seconds.
+        # 60 iterations between syncs or sync if dirty every ~30 seconds
         iterations_between_sync = 60
 
-        while True:
-            (request, client_address) = self.requestqueue.get()
+        while not self.quit:
+            try:
+                (request, client_address) = self.requestqueue.get(True, 30)
+            except Queue.Empty:
+                self.table.sync_if_dirty()
+                continue
             try:
                 self.finish_request(request, client_address)
                 self.shutdown_request(request)
@@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
                 self.handle_error(request, client_address)
                 self.shutdown_request(request)
                 self.table.sync()
+            self.table.sync_if_dirty()
 
     def process_request(self, request, client_address):
         self.requestqueue.put((request, client_address))
@@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
         self.handlerthread.start()
         while not self.quit:
             self.handle_request()
-
+        self.handlerthread.join()
         self.table.sync()
         logger.info("PRServer: stopping...")
         self.server_close()




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] prserv/serv: Improve exit handling
@ 2015-09-02 17:20 Saul Wold
  2015-09-02 17:27 ` Martin Jansa
  0 siblings, 1 reply; 4+ messages in thread
From: Saul Wold @ 2015-09-02 17:20 UTC (permalink / raw)
  To: bitbake-devel; +Cc: akuster808

From: Richard Purdie <richard.purdie@linuxfoundation.org>

Currently, I'm not sure how the prserver managed to shut down cleanly. These
issues may explain some of the hangs people have reported.

This change:

* Ensures the connection acceptance thread monitors self.quit
* We wait for the thread to exit before exitting
* We sync the database when the thread exits
* We do what the comment mentions, timeout after 30s and sync the database
  if needed. Previously, there was no timeout (the 0.5 applies to sockets,
  not the Queue object)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4)
Signed-off-by: Saul Wold <sgw@linux.intel.com>
---
 lib/prserv/serv.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index 25eb46a..a7639c8 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
 
         """
         iter_count = 1
-        # With 60 iterations between syncs and a 0.5 second timeout between
-        # iterations, this will sync if dirty every ~30 seconds.
+        # 60 iterations between syncs or sync if dirty every ~30 seconds
         iterations_between_sync = 60
 
-        while True:
-            (request, client_address) = self.requestqueue.get()
+        while not self.quit:
+            try:
+                (request, client_address) = self.requestqueue.get(True, 30)
+            except Queue.Empty:
+                self.table.sync_if_dirty()
+                continue
             try:
                 self.finish_request(request, client_address)
                 self.shutdown_request(request)
@@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
                 self.handle_error(request, client_address)
                 self.shutdown_request(request)
                 self.table.sync()
+            self.table.sync_if_dirty()
 
     def process_request(self, request, client_address):
         self.requestqueue.put((request, client_address))
@@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
         self.handlerthread.start()
         while not self.quit:
             self.handle_request()
-
+        self.handlerthread.join()
         self.table.sync()
         logger.info("PRServer: stopping...")
         self.server_close()
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] prserv/serv: Improve exit handling
  2015-09-02 17:20 [PATCH] prserv/serv: Improve exit handling Saul Wold
@ 2015-09-02 17:27 ` Martin Jansa
  2015-09-02 21:49   ` Saul Wold
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2015-09-02 17:27 UTC (permalink / raw)
  To: Saul Wold; +Cc: akuster808, bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 3078 bytes --]

On Wed, Sep 02, 2015 at 10:20:06AM -0700, Saul Wold wrote:
> From: Richard Purdie <richard.purdie@linuxfoundation.org>

The subject doesn't say for which branch this is intended.

I guess 1.24, because it's already in 1.26 and master, but it should be
specified in Subject.

> 
> Currently, I'm not sure how the prserver managed to shut down cleanly. These
> issues may explain some of the hangs people have reported.
> 
> This change:
> 
> * Ensures the connection acceptance thread monitors self.quit
> * We wait for the thread to exit before exitting
> * We sync the database when the thread exits
> * We do what the comment mentions, timeout after 30s and sync the database
>   if needed. Previously, there was no timeout (the 0.5 applies to sockets,
>   not the Queue object)
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> (cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4)
> Signed-off-by: Saul Wold <sgw@linux.intel.com>
> ---
>  lib/prserv/serv.py | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
> index 25eb46a..a7639c8 100644
> --- a/lib/prserv/serv.py
> +++ b/lib/prserv/serv.py
> @@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
>  
>          """
>          iter_count = 1
> -        # With 60 iterations between syncs and a 0.5 second timeout between
> -        # iterations, this will sync if dirty every ~30 seconds.
> +        # 60 iterations between syncs or sync if dirty every ~30 seconds
>          iterations_between_sync = 60
>  
> -        while True:
> -            (request, client_address) = self.requestqueue.get()
> +        while not self.quit:
> +            try:
> +                (request, client_address) = self.requestqueue.get(True, 30)
> +            except Queue.Empty:
> +                self.table.sync_if_dirty()
> +                continue
>              try:
>                  self.finish_request(request, client_address)
>                  self.shutdown_request(request)
> @@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
>                  self.handle_error(request, client_address)
>                  self.shutdown_request(request)
>                  self.table.sync()
> +            self.table.sync_if_dirty()
>  
>      def process_request(self, request, client_address):
>          self.requestqueue.put((request, client_address))
> @@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
>          self.handlerthread.start()
>          while not self.quit:
>              self.handle_request()
> -
> +        self.handlerthread.join()
>          self.table.sync()
>          logger.info("PRServer: stopping...")
>          self.server_close()
> -- 
> 2.1.0
> 
> -- 
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] prserv/serv: Improve exit handling
  2015-09-02 17:27 ` Martin Jansa
@ 2015-09-02 21:49   ` Saul Wold
  0 siblings, 0 replies; 4+ messages in thread
From: Saul Wold @ 2015-09-02 21:49 UTC (permalink / raw)
  To: Martin Jansa; +Cc: akuster808, bitbake-devel

On 09/02/2015 10:27 AM, Martin Jansa wrote:
> On Wed, Sep 02, 2015 at 10:20:06AM -0700, Saul Wold wrote:
>> From: Richard Purdie <richard.purdie@linuxfoundation.org>
>
> The subject doesn't say for which branch this is intended.
>
> I guess 1.24, because it's already in 1.26 and master, but it should be
> specified in Subject.
>
Yes it is for 1.24, I can resend, but I think RP knows that this is for 
1.24 also.

Sau!

>>
>> Currently, I'm not sure how the prserver managed to shut down cleanly. These
>> issues may explain some of the hangs people have reported.
>>
>> This change:
>>
>> * Ensures the connection acceptance thread monitors self.quit
>> * We wait for the thread to exit before exitting
>> * We sync the database when the thread exits
>> * We do what the comment mentions, timeout after 30s and sync the database
>>    if needed. Previously, there was no timeout (the 0.5 applies to sockets,
>>    not the Queue object)
>>
>> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
>> (cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4)
>> Signed-off-by: Saul Wold <sgw@linux.intel.com>
>> ---
>>   lib/prserv/serv.py | 14 +++++++++-----
>>   1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
>> index 25eb46a..a7639c8 100644
>> --- a/lib/prserv/serv.py
>> +++ b/lib/prserv/serv.py
>> @@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
>>
>>           """
>>           iter_count = 1
>> -        # With 60 iterations between syncs and a 0.5 second timeout between
>> -        # iterations, this will sync if dirty every ~30 seconds.
>> +        # 60 iterations between syncs or sync if dirty every ~30 seconds
>>           iterations_between_sync = 60
>>
>> -        while True:
>> -            (request, client_address) = self.requestqueue.get()
>> +        while not self.quit:
>> +            try:
>> +                (request, client_address) = self.requestqueue.get(True, 30)
>> +            except Queue.Empty:
>> +                self.table.sync_if_dirty()
>> +                continue
>>               try:
>>                   self.finish_request(request, client_address)
>>                   self.shutdown_request(request)
>> @@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
>>                   self.handle_error(request, client_address)
>>                   self.shutdown_request(request)
>>                   self.table.sync()
>> +            self.table.sync_if_dirty()
>>
>>       def process_request(self, request, client_address):
>>           self.requestqueue.put((request, client_address))
>> @@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
>>           self.handlerthread.start()
>>           while not self.quit:
>>               self.handle_request()
>> -
>> +        self.handlerthread.join()
>>           self.table.sync()
>>           logger.info("PRServer: stopping...")
>>           self.server_close()
>> --
>> 2.1.0
>>
>> --
>> _______________________________________________
>> bitbake-devel mailing list
>> bitbake-devel@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-02 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-02 17:20 [PATCH] prserv/serv: Improve exit handling Saul Wold
2015-09-02 17:27 ` Martin Jansa
2015-09-02 21:49   ` Saul Wold
  -- strict thread matches above, loose matches on Subject: below --
2015-01-21 13:53 Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.