Questions tagged [anyevent]

AnyEvent is a Perl framework for event-based programming

AnyEvent(similar to POE and Twisted) is a framework for event-based programming. It comes with a number of different implementations while maintaining the same API(unless otherwise mentioned in the documentation). The current implementations are POE,Perl(pure Perl),IOAsync,EV,Event,EventLib,Cocoa,FLTK,Glib,Irssi,Qt,Tk.

It can be used for building high-performance applications that scale well. At the same time, synchronization primitives are available(condition variables), polling(via poll or epoll), running periodic tasks, inotify support(via AnyEvent::Filesys::Notify), database support(via AnyEvent::DBI), forking(via AnyEvent::Fork) and it comes with a built-in non-blocking HTTP client(AnyEvent::HTTP). There are many modules that extend AnyEvent's functionality which can be found on CPAN.

85 questions
4
votes
1 answer

AnyEvent->timer not working with AnyEvent::Handle?

I'm trying to build a timeout scenario in my Catalyst, AnyEvent, Websocket app. For that I'm using AnyEvent->timer which should be called after let's say a few seconds of inactivity (no more WS frames coming in). The problem is, that my timer is…
RandomAndy
  • 324
  • 1
  • 9
4
votes
1 answer

Errors with AnyEvent in Windows Perl

I try to use AnyEvent's fork_call in Windows Perl. I wrote some sample code: use AnyEvent; use AnyEvent::Util; use Data::Dumper; my $cv = AnyEvent -> condvar; my $a; fork_call { $a = 1; $cv -> send; }, sub { $cv -> recv; print…
michaeluskov
  • 1,729
  • 7
  • 27
  • 53
4
votes
2 answers

AnyEvent fork_call and ping

I'm trying to create a perl module that pings (using the linux system ping) to hundreds of hosts, and get the data of the ping (like packet loss and how much packets transmitted and how much received and etc.) from the stdout of each host. I used…
Adamba4
  • 181
  • 1
  • 2
  • 9
4
votes
2 answers

how to use AnyEvent::Handler with socket that has port reuse

Recently I ran into a great perl module "AnyEvent", which allows user to do asynchronous/event-driven programing. Created the following snippet which works fine. The problem I have is that after it opens and closes lots sockets, it quickly exhausted…
pktCoder
  • 1,105
  • 2
  • 15
  • 32
4
votes
2 answers

Threads, Coro, Anyevent confusion

I am relatively new to perl and even newer to threading in perl. I have a perl script that takes input from 3 different sources. (2 LDAP queries and a file that isn't always there) Because some parts can take longer than others so I decided to use…
jaden
  • 55
  • 6
4
votes
3 answers

is there a way to view the AnyEvent event queue

I'm working on a Perl project written asynchronously using AnyEvent. During testing, I had a situation where a bug in my code caused blocked code to be called after my test had completed so the test looked like it passed, but the blocked call ended…
tbischel
  • 6,337
  • 11
  • 51
  • 73
3
votes
1 answer

Avoid Mojolicious async beviour? Avoid "AnyEvent::CondVar: recursive blocking wait attempted"

We have a library that uses AnyEvent already. It uses AnyEvent internally and in the end it returns a value (synchronously - not with a callback). Is there any way I can use this library with Mojolicious? It does something like: #!/usr/bin/perl use…
Peter V. Mørch
  • 13,830
  • 8
  • 69
  • 103
3
votes
1 answer

Is it possible to make something like longjump in Perl inside EV callbacks?

I am trying to emulate synchronous control flow in an asynchronous environment. The purpose is to support DB requests without callbacks or blocking on request. I am trying to use the Coro module, but I think I don't understand it in full. Here are…
3
votes
2 answers

Why won't AnyEvent::child callbacks ever run if interval timer events are always ready?

Update this issue can be resolved using the fixes present in https://github.com/zbentley/AnyEvent-Impl-Perl-Improved/tree/io-starvation Context: I am integrating AnyEvent with some otherwise-synchronous code. The synchronous code needs to install…
Zac B
  • 3,796
  • 3
  • 35
  • 52
3
votes
1 answer

Howto deal with AnyEvent, RabbitMQ (heartbeat) and long running jobs in Perl?

I am implementing a system for distributed cronjob execution (so called cron computing cluster). Cronjobs should be queued into a message queue (RabbitMQ) when the time of action is there. On the other side (the nodes/workers of the cluster) is a…
burnersk
  • 3,320
  • 4
  • 33
  • 56
3
votes
2 answers

How to disconnect from RabbitMQ properly using Perl's AnyEvent::RabbitMQ?

I want to disconnect from RabbitMQ in a proper way. By reviewing the source code of Perl's AnyEvent::RabbitMQ (which I am using), I found the close method which seems to close all the channels opened to RabbitMQ. So I connected to RabbitMQ opened…
burnersk
  • 3,320
  • 4
  • 33
  • 56
3
votes
2 answers

Reconnect using AnyEvent::Handle and tcp_connect

I have a simple TCP server and client written using AnyEvent::Handle leveraging tcp_connect and tcp_server. The client connects to the server and sends the string Test Message every 5 seconds. This works without issue if the server is reachable,…
Sgt B
  • 1,211
  • 2
  • 11
  • 21
3
votes
1 answer

AnyEvent::Fork how to wait for child

I am looking at the AnyEvent::Fork module. I have 20 external scripts I would like to invoke in parallel (6 at a time) and summarize their output later when all finished. I am at loss how to achieve this. The example code (that only invokes 1 child)…
cstamas
  • 378
  • 2
  • 13
3
votes
1 answer

Why isn't on_eof called in this AnyEvent::Handle example?

This is my simple server. When I run it and telnet to it (port 5222), and have the telnet quit its connection, why isn't my on_eof function called? I.e. why isn't the string "CATASTROPHE!!!" printed? #!/usr/bin/perl use v5.18; use warnings; use…
alexk
  • 1,488
  • 1
  • 12
  • 17
3
votes
1 answer

Using synthetic filehandle with EV (perl)

I have a filehandle object that is created thus (edited slightly for clarity): sub TIEHANDLE { return $_[0] if ref($_[0]); my $class = shift; my $self = bless Symbol::gensym(), $class; return $self; } sub new { my ($class, $fh,…
awy
  • 5,271
  • 5
  • 23
  • 28