open() with pipe breaks AnyEvent STDIN poll
Nick Andrew
nick at nick-andrew.net
Thu Nov 27 14:42:42 CET 2014
G'day Marc,
On Wed, Nov 26, 2014 at 06:16:57PM +0100, Marc Lehmann wrote:
> Together with "for" localising but "while" not - one of the vestiges of
> perl that we all love, no? :)
Yeah. At work we've got a large amount of perl code written by programmers
of, err, "varying" skill levels, with little consistency even within
applications. For that reason I'm very concerned about the use of any
techniques which can cause spooky action at a distance, including:
* use lib
* $Data::Dumper::Indent [etc]
* BEGIN blocks
I've looked at parsing our perl code to detect dangerous idioms but
learned how it's an essentially unparseable language (although the PPI module
does very well) and so fighting against bad code is an ongoing effort.
In the case of global $_ I agree that AnyEvent::Strict identifies the
problem as soon as it occurs (in my case, that's every time) but more
generally, considering the challenges of programming within my work,
I figure that there are two ways to avoid being bitten by a problem
like this, one is to not cause the problem (somebody else's code)
and the other is to protect my code from somebody else's failure.
The outcome for me of this problem hitting was a server spinning
in a tight select() loop with lots of CPU time being used and a
good handful of processes doing it ... which caused high loadavg,
which caused an alarm, which caused somebody to investigate and
find it was my processes and then contact me to find out what was
going on. So I'm pretty biased toward prevention.
On another subject ...
You may be interested; I wrote a small "framework" which uses AnyEvent
and its main purpose is to enable asynchronous process-to-process
communication, even across an ssh connection. So it becomes trivial
to write a "server" process which runs on a remote host, exchanging
data structures with a "client" process. The code's online in github:
https://github.com/nickandrew/anyevent-ttyserver
I called it AnyEvent::TtyServer for want of a better name. There
are already many AnyEvent derived modules on CPAN and quite possibly
some which overlap in functionality, but my goal here was to make
it as easy as possible to write a client or server.
Nick.
--
PGP Key ID = 0x418487E7 http://www.nick-andrew.net/
PGP Key fingerprint = B3ED 6894 8E49 1770 C24A 67E3 6266 6EB9 4184 87E7
More information about the anyevent
mailing list