Merge lp:~vaab/openobject-server/fix-ircron-utf8-error2 into lp:openobject-server/6.1

Proposed by Valentin Lab
Status: Needs review
Proposed branch: lp:~vaab/openobject-server/fix-ircron-utf8-error2
Merge into: lp:openobject-server/6.1
Diff against target: 18 lines (+2/-2)
1 file modified
openerp/addons/base/ir/ir_cron.py (+2/-2)
To merge this branch: bzr merge lp:~vaab/openobject-server/fix-ircron-utf8-error2
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+104750@code.launchpad.net

Description of the change

job['name'] can be quite long and not very system friendly (unicode, spaces, and other characters).

The unicode part is translated in threading module thanks to "str(name)", which fails on non-ASCII characters. See the linked bug report.

It happens that I use the thread name in my logging facility, and having very long thread name is not very convenient. And conversion towards unicode is done back in the logging facility. So explicit "utf-8" encoding seems bad.

So it seems to make sense to me to use a full ASCII, small, and unique identifier as the threadname here.

Any comments ?

To post a comment you must log in.

Unmerged revisions

4160. By Valentin Lab

[FIX] ir_cron should encode the unicode job name.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/addons/base/ir/ir_cron.py'
--- openerp/addons/base/ir/ir_cron.py 2012-02-02 09:21:05 +0000
+++ openerp/addons/base/ir/ir_cron.py 2012-05-04 14:43:20 +0000
@@ -234,12 +234,12 @@
234 task_cr.close()234 task_cr.close()
235235
236 # Got the lock on the job row, now spawn a thread to execute it in the transaction with the lock236 # Got the lock on the job row, now spawn a thread to execute it in the transaction with the lock
237 task_thread = threading.Thread(target=self._run_job, name=job['name'], args=(task_cr, job, now))237 task_thread = threading.Thread(target=self._run_job, name="ir_cron-%d" % (job['id'], ), args=(task_cr, job, now))
238 # force non-daemon task threads (the runner thread must be daemon, and this property is inherited by default)238 # force non-daemon task threads (the runner thread must be daemon, and this property is inherited by default)
239 task_thread.setDaemon(False)239 task_thread.setDaemon(False)
240 openerp.cron.take_thread_slot()240 openerp.cron.take_thread_slot()
241 task_thread.start()241 task_thread.start()
242 _logger.debug('Cron execution thread for job `%s` spawned', job['name'])242 _logger.debug('Cron execution thread for job `%s` spawned (thread-id: %s)', job['name'], task_thread.name)
243243
244 # Find next earliest job ignoring currently processed jobs (by this and other cron threads)244 # Find next earliest job ignoring currently processed jobs (by this and other cron threads)
245 find_next_time_query = """SELECT min(nextcall) AS min_next_call245 find_next_time_query = """SELECT min(nextcall) AS min_next_call