Re: Question on Reloading Modules in POE server
Georg Moritz <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
From the keyboard of ty [27.10.08,07:56]:
> I have a POE server that spawns some sessions that use
> POE::Component::Generic. Each of these sessions act as a separate
> tool in the server. From time to time, I have to make changes to a
> module that is used by one of the sessions. It requires me to restart
> the server now so that the new changes are reflected. It would be
> nice if there was a way to tell the session to reload the module like
> it is possible in mod_perl with various apache modules. I came across
> a post on this group in 2005 titled Unuse Modules, but this was
> looking at the problem from getting them out of the system not
> reloading. Module::Refresh seems to be a possible solution. However,
> I wanted to know if anyone has successfully done something like this
> in the context of POE running in a persistent environment?
>
> Best Regards
>
> Ty
Reloading an entire Module can be icky if in addition to undefining the
%INC entry you need to undefine the entire symbol table (e.g. to get rid
of garbage accumulated in that namespace), in which case objects of that
package get re-blessed into the __ANON__ package.
If you just have to modify methods of a class or functions of a module
or package, you could go with AutoReloader by yours truly, which is a
drop-in replacement for AutoLoader and designed for just your type of
apps in mind (see http://search.cpan.org/search?query=AutoReloader
and http://perlmonks.org/?node_id=600805 ).
Of course that means splitting up your module into separate files as
e.g. POSIX in the core distribution.
cheers
0--gg-
--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s,/,($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e,e && print}