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
8
votes
4 answers

Writing good object-oriented code under AnyEvent

We're building a large application with complex logic, which is composed of modules. I used to build larger scale methods of simpler methods, for instance, # fig. 1 package Foo; sub highlevel { my ($self, $user, $event) = @_; my $session…
Dallaylaen
  • 5,268
  • 20
  • 34
6
votes
1 answer

AnyEvent::RabbitMQ issues with closed channels

I'm writing a master program for publishing message into a message queue (RabbitMQ). The program is written in Perl 5 and is using AnyEvent::RabbitMQ for the communication to RabbitMQ. The following minimal example (for the issue I ran into) will…
burnersk
  • 3,320
  • 4
  • 33
  • 56
6
votes
1 answer

How to run external command in parallel using AnyEvent and Perl

I'm new to Perl 5 asynchronous processes and find it exciting that CPAN offers similar support that we can do in Node.js with AnyEvent, IO::Async, etc. However, the tutorial provides a few examples for complicated stuff. What I need is only to run…
est
  • 557
  • 1
  • 4
  • 17
5
votes
2 answers

AnyEvent timer question

How could I make "visible" the timer? This example returns (intependent from the sleep-time always) 2 (I expected something similar to the sleep-time). #!/usr/local/bin/perl use warnings; use 5.014; use AnyEvent; my $c = 0; my $cv =…
sid_com
  • 24,137
  • 26
  • 96
  • 187
5
votes
1 answer

How to use AnyEvent::HTTP to get only part of the page?

It is necessary to read only part of the page (n bytes) and close the connection, how to do this on AnyEvent::HTTP ?
Dmitriy
  • 463
  • 1
  • 5
  • 12
5
votes
2 answers

Understanding async in perl on specific example

I have to write a script that get some URLs in parallel and do some work. In the past I have always used Parallel::ForkManager for such things, but now I wanted to learn something new and try asynchronous programming with AnyEvent (and…
alan
  • 111
  • 6
5
votes
1 answer

Why must an AnyEvent timer watcher be undef'ed in its callback to fire?

While trying to understand AnyEvent, I create two timers which print to screen each time they're fired. Initially neither worked. But following Joshua Barratt's timer example, I found that if I didn't undef the timer's watcher variable then the…
Le Jeune Renard
  • 400
  • 1
  • 8
5
votes
1 answer

How to stop MainLoop in Perl/Tk + AnyEvent

I'm writing Perl/Tk program which uses AnyEvent's timer. And I have a problem with closing window if timer is active. I made this window close handler: $self -> {window} -> protocol( 'WM_DELETE_WINDOW' => sub { …
michaeluskov
  • 1,729
  • 7
  • 27
  • 53
5
votes
2 answers

Using AnyEvent run_cmd in Mojolicious, I keep getting this error: "AnyEvent::CondVar: recursive blocking wait attempted"

In a Mojolicious app, I'm trying to convert ODT files into HTML when a link is clicked. I convert the files by using "soffice", a shell command. Converting the files takes some time. I send status messages to the user to notify him of the progress.…
5
votes
1 answer

How to do asynchronous www-mechanize using anyevent

I've been doing a fair amount of research on the topic and while there are some questions out there that relate, I'm really having a hard time understanding how to properly do async programming using AnyEvent and www-mechanize. I'm trying to stick…
mikew
  • 912
  • 2
  • 11
  • 22
5
votes
3 answers

Creating A Single Threaded Server with AnyEvent (Perl)

I'm working on creating a local service to listen on localhost and provide a basic call and response type interface. What I'd like to start with is a baby server that you can connect to over telnet and echoes what it receives. I've heard AnyEvent…
David Williams
  • 8,388
  • 23
  • 83
  • 171
4
votes
2 answers

Perl Anyevent , non blocking redis push

I have the code below to do non blocking rpush into a redis server When I run this for just 1 rpush , the code works fine But when I run this in a while loop the script hangs after the first execution. Why ? #!/usr/bin/perl …
Ram
  • 1,155
  • 13
  • 34
4
votes
1 answer

Keep a perl script running

I have a perl script that subscribes to a message queue using AnyEvent::MQTT. At the minute all I want it to do is print out when it get's a message. I'm totally new to perl so I'm using the demo code it comes with which includes a bit that…
Ross Dargan
  • 5,876
  • 4
  • 40
  • 53
4
votes
2 answers

AnyEvent file writes plus logrotate lead to unexpected file sizes

I have a script that writes out to a file on a frequent basis using AnyEvent. I've written the following sample to illustrate the issue I'm facing. #!/usr/bin/perl use strict; use warnings; use AnyEvent; use AnyEvent::Handle; my $outputFile =…
Sgt B
  • 1,211
  • 2
  • 11
  • 21
4
votes
2 answers

Installed module not found when running program

Context Here is a perl test script, in which I wanted to see how you can use a specific event loop with AnyEvent : # file test.pl : #!/usr/bin/perl use strict; use warnings; use AnyEvent; use AnyEvent::Impl::EV; my $cv = AnyEvent->condvar; my…
LeGEC
  • 46,477
  • 5
  • 57
  • 104
1
2 3 4 5 6