Opened 11 years ago

Last modified 11 years ago

#611 enhancement closed fixed (fixed)

Allow scheduling for log observers

Reported by: itamarst Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: glyph, exarkun, itamarst Branch:
Author: Launchpad Bug:

Description


Change History (5)

comment:1 Changed 11 years ago by itamarst

We want observer to always run in reactor thread:

  log.addObserver(f, scheduler=reactor.callFromThread)

or wxCallAfter for wx thread. Also we can support blocking observers such as the
logging framework in stdlib:

  log.addObserver(f, scheduler=reactor.callInThread)

etc..

comment:2 Changed 11 years ago by itamarst

Alternative is to just document the fact you can do this. If we had logging
docs, anyway. But this is kinda elegant.

comment:3 Changed 11 years ago by glyph

Alternative is to document what?

I'm not sure I fully understand you, but if you mean to say that you can do

log.addObserver(f, scheduler=reactor.callInThread)

and that will reactor.callInThread(f, msg) - that is just terrible.  You can
easily do

log.addObserver(lambda msg: reactor.callInThread(f,msg))

in your client code and avoid adding any more complexity to the logging system.
 Considering the main thing the logging system has going for it at the moment is
simplicity I would not want to make it worse by adding that.

Note, I also think my suggestion is a horrible idea, because the log publisher
is already thread-safed specifically because you don't necessarily know which
thread wants to log.  If you want a smart logger, you need to check whether it's
the reactor thread in your observer every time.

comment:4 Changed 11 years ago by itamarst

oh well.

comment:5 Changed 4 years ago by <automation>

  • Owner itamarst deleted
Note: See TracTickets for help on using tickets.