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
=== modified file 'openerp/service/__init__.py'
--- openerp/service/__init__.py 2013-06-12 15:19:12 +0000
+++ openerp/service/__init__.py 2014-05-29 11:16:08 +0000
@@ -94,6 +94,14 @@
94 # Start the main cron thread.94 # Start the main cron thread.
95 cron.start_service()95 cron.start_service()
9696
97def log_repeating_message(msg, counter):
98 '''Utility function to log repeated messages, withouth overflowing log'''
99 if (counter <= 10
100 or (counter <= 100 and (counter % 10 == 0))
101 or (counter <= 1000 and (counter % 100 == 0))
102 or (counter > 1999 and (counter % 1000 == 0))):
103 _logger.debug('%d: %s' % (counter, msg))
104
97def stop_services():105def stop_services():
98 """ Stop all services. """106 """ Stop all services. """
99 # stop services107 # stop services
@@ -112,8 +120,11 @@
112 for thread in threading.enumerate():120 for thread in threading.enumerate():
113 _logger.debug('process %r (%r)', thread, thread.isDaemon())121 _logger.debug('process %r (%r)', thread, thread.isDaemon())
114 if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:122 if thread != me and not thread.isDaemon() and thread.ident != main_thread_id:
123 msg_counter = 0
124 msg = 'join and sleep %s' % thread.name
115 while thread.isAlive():125 while thread.isAlive():
116 _logger.debug('join and sleep')126 msg_counter += 1
127 log_repeating_message(msg, msg_counter)
117 # Need a busyloop here as thread.join() masks signals128 # Need a busyloop here as thread.join() masks signals
118 # and would prevent the forced shutdown.129 # and would prevent the forced shutdown.
119 thread.join(0.05)130 thread.join(0.05)