Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: IKEDA Soji <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed
  • Date: Sat, 7 Jun 2014 00:04:40 +0900

Hi,

On Fri, 06 Jun 2014 16:24:34 +0200
Guillaume Rousse <address@concealed> wrote:

> Le 06/06/2014 08:45, IKEDA Soji a écrit :
> > Guillaume,
> >
> > On Wed, 28 May 2014 13:18:52 +0200
> > Guillaume Rousse <address@concealed> wrote:
> >
> >> Le 27/05/2014 15:54, IKEDA Soji a écrit :
> >>> Hi,
> >>>
> >>> How about using Class::Autouse?
> >> That would seem merely hiding the dust behind the carpet, at the cost of
> >> additional external code moreover.
> >>
> >> I prefer to adresse the actual problem at the source, and find some way
> >> to pass the relevant parameters directly. Just passing a Sympa::Site
> >> instance, or using a global $main::site instance, for instance, would be
> >> enough in most cases.
> >
> > I wish to keep "logs_failed" notification feature in log module.
> There is no 'log failed' event, because logging never fails... More
> exactly, Sys::Syslog::syslog() always return 1 (it is hardcoded in XS
> code), and the underlying native C syslog function has void as return
> type. So trying to catch a log failure is quite futile.

I see. I investigate this feature more.

> > Log module looks being used by most of other modules including Site.
> >
> > So, I at first did like:
> >
> > use Sympa::Site;
> > use Sympa::Logger;
> >
> > my $logger = Sympa::Logger->instance;
> > $logger->set_options(
> > log_level => Sympa::Site->log_level,
> >
> > # Other options...
> >
> > fault_handler => sub {
> > Sympa::Site->send_notify_to_listmaster('logs_failed');
> > }
> > );
> >
> > # The first speech
> > $logger->do_log('notice', 'MYDAEMON started');
> >
> > Sympa::Logger need not use Sympa::Site explicitly. Alternatively,
> > if syslog is broken, Sympa::Logger::do_log() would call fault_handler.
> That would a fine solution, indeed, excepted for the previous issue.
>
> > ...However, this solution is essentially not neccessary. Anytime
> > when do_log() is called, inevitablly Sympa::Site has been loaded.
> > Sympa::Logger can freely call send_notify_to_listmaster() by itself.
> That's wrong in testing scenarios, and potentially in multiple tools
> from the src/bin directory that may require only a subset of Sympa
> codebase in memory.
>
> More generally, assuming a package has been transitively loaded in
> memory by current package depencies is a fragile assumption, and won't
> survive refactoring very long.

On the tests, preparing environment in proper quantities is a matter
of course. Test scripts should load required all modules at first.

In the first place, current dependency loop is a sham, I think.
If it was not, programs will try to load modules eternally and at
last they will crash by stack overflow. So it would be resolved
anyway.

I suppose the problem you are struggling is caused because required
modules are not explicitly specified in the source, not because
they are not practically loaded.

> > I think the situation is same on task instruction. When the task is
> > running, is it possible that the module like Sympa::List has not been
> > loaded?
> t/instruction.t, for instance.

Well, required use lines should be added.


Regards,

--- Soji

--
株式会社 コンバージョン セキュリティ&OSSソリューション部 池田荘児
〒231-0004 神奈川県横浜市中区元浜町3-21-2 ヘリオス関内ビル7F
e-mail address@concealed TEL 045-640-3550
http://www.conversion.co.jp/



Archive powered by MHonArc 2.6.19+.

Top of Page