Closed Bug 1016534 Opened 10 years ago Closed 10 years ago

pulsebuildmonitor silently fails if no logger is provided

Categories

(Webtools :: Pulse, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mcote, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Seems that worker threads silently die if you leave the 'logger' arg of start_pulse_monitor() at is default value of None.  This is a problem because PulseBuildMonitor does not always check if self.logger is not None before attempting to use it, and since it's in its own thread, the exceptions disappear.

Assuming we want to keep the behaviour of not doing any logging if logger is None, the fix is just to put more checks in--although a more foolproof fix would be to create some sort of NullLogger if logger is passed in as None.
Hm further weirdness: if self.logger exists, PulseBuildMonitor not only logs exceptions but also prints them to stderr via traceback.print_exc().  If self.logger isn't set, then it doesn't print them to stderr.  That doesn't make a lot of sense to me.
Spreading some pulse reviews around. :)

To avoid a bunch of "if self.logger" calls, which clearly can be easily forgotten, if logger is passed in as None, PulseBuildMonitor now uses a logger with name 'pulsebuildmonitor' with a NullHandler.

I also removed the print_exc() calls, since if desired the client can always pass in a logger with a StreamHandler.

Finally I removed the unused json/simplejson import.
Attachment #8429717 - Flags: review?(hskupin)
Forgot to remove the traceback import, which is no longer used.
Attachment #8429717 - Attachment is obsolete: true
Attachment #8429717 - Flags: review?(hskupin)
Attachment #8430096 - Flags: review?(hskupin)
Comment on attachment 8429717 [details] [diff] [review]
Fix logging when no logger provided

Review of attachment 8429717 [details] [diff] [review]:
-----------------------------------------------------------------

Looks fine to me, and it makes sense. Why not also updating the version number in setup.py? Are other changes coming up?

Maybe you should also ask jgriffin for review, given that I'm not an official reviewer for this project.
Attachment #8429717 - Attachment is obsolete: false
Attachment #8429717 - Attachment is obsolete: true
Comment on attachment 8430096 [details] [diff] [review]
Fix logging when no logger provided

Review of attachment 8430096 [details] [diff] [review]:
-----------------------------------------------------------------

As what I said on the other patch.
Attachment #8430096 - Flags: review?(hskupin) → review+
Yeah, I want to (separately) bump the version requirement of mozillapulse so that ssl is on by default.  And I may also wait until we change the exchange and queue naming conventions.
jgriffin says he trusts you. :)

http://hg.mozilla.org/automation/pulsebuildmonitor/rev/6bedbff3258e
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: