Merge lp:~therp-nl/openobject-server/7.0_lp1298258_join_and_sleep into lp:openobject-server/7.0

Proposed by Ronald Portier (Therp)
Status: Needs review
Proposed branch: lp:~therp-nl/openobject-server/7.0_lp1298258_join_and_sleep
Merge into: lp:openobject-server/7.0
Diff against target: 31 lines (+12/-1)
1 file modified
openerp/service/__init__.py (+12/-1)
To merge this branch: bzr merge lp:~therp-nl/openobject-server/7.0_lp1298258_join_and_sleep
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+221358@code.launchpad.net

Description of the change

Prevent log from filling up with messages when there are difficulties ending all threads on server stop.

To post a comment you must log in.

Unmerged revisions

5308. By Ronald Portier (Therp)

[FIX] Prevent filling up log with messages when there are difficulties
    ending all threads on server stop.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/service/__init__.py'
2--- openerp/service/__init__.py 2013-06-12 15:19:12 +0000
3+++ openerp/service/__init__.py 2014-05-29 11:16:08 +0000
4@@ -94,6 +94,14 @@
5 # Start the main cron thread.
6 cron.start_service()
7
8+def log_repeating_message(msg, counter):
9+ '''Utility function to log repeated messages, withouth overflowing log'''
10+ if (counter <= 10
11+ or (counter <= 100 and (counter % 10 == 0))
12+ or (counter <= 1000 and (counter % 100 == 0))
13+ or (counter > 1999 and (counter % 1000 == 0))):
14+ _logger.debug('%d: %s' % (counter, msg))
15+
16 def stop_services():
17 """ Stop all services. """
18 # stop services
19@@ -112,8 +120,11 @@
20 for thread in threading.enumerate():
21 _logger.debug('process %r (%r)', thread, thread.isDaemon())
22 if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:
23+ msg_counter = 0
24+ msg = 'join and sleep %s' % thread.name
25 while thread.isAlive():
26- _logger.debug('join and sleep')
27+ msg_counter += 1
28+ log_repeating_message(msg, msg_counter)
29 # Need a busyloop here as thread.join() masks signals
30 # and would prevent the forced shutdown.
31 thread.join(0.05)