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
1
vote
0 answers

perl script with AnyEvent is not going fast enough

Here is the little script I created to do HTTP transactions from a file with a list of URLs. The problem is that it's not able to do HTTP transactions as fast as I would like. More precisely, I set the rate to be 200/seconds, but it was able to…
pktCoder
  • 1,105
  • 2
  • 15
  • 32
1
vote
1 answer

How can I wait for the completion of http_request in AnyEvent::HTTP?

The program takes jobs from the database and executes AnyEvent::HTTP::http_request, how to correctly exit the program, after waiting for the completion of all requests? #!/usr/bin/perl use strict; use AnyEvent; use AnyEvent::DBI; use…
Dmitriy
  • 463
  • 1
  • 5
  • 12
1
vote
0 answers

AnyEvent Fork::Pool vs Worker::Pool

Background I need to write a program which launches, monitors and reports the status of upto a few thousands of shell scripts. I find two modules in the AnyEvent space (AnyEvent::Fork::Pool and AnyEvent::Worker::Pool) which seem to do the work The…
vijayvithal
  • 551
  • 1
  • 5
  • 13
1
vote
1 answer

How do you "sleep" in an AnyEvent callback without pausing the whole script?

I'm specificaly using AnyEvent::Inotify::Simple (using EV as backend) to monitor file events. So I have a handler callback that in a particular case, I need to "pause" before continuing. sleep obviously halts everything (so other events don't get…
FunkyShu
  • 138
  • 5
1
vote
0 answers

Forwarding AnyEvent::Log messages to a callback if certain requirements are met

I am working on a project that uses AnyEvent Log in the main program as well as several dependent modules/packages. I currently have each module writing to it's own context, and all contexts are added to the main programs context as slaves. This…
linjoy
  • 11
  • 1
1
vote
1 answer

Multiple telnet clients/commands under AnyEvent

If I'm reading multiple $_->{thand}->cmd($cmd) commands through same telnet connection, I've got disconnects. This manifests as multiple calls to ae_connect(). How to properly send and fetch data under AnyEvent? use strict; use warnings; use…
mpapec
  • 50,217
  • 8
  • 67
  • 127
1
vote
1 answer

Can I use lock from the threads::shared module like a mutex?

i'm using AnyEvent to trigger event every X minutes. Some process are long and the result to record in the database are sometimes long to record (more than 3 seconds sometimes). I want to be sure that there is only one function that access to my…
1
vote
0 answers

Code based on AnyEvent::Socket working is unstable

I am create memcached client with AnyEvent (for study) and implemented the folowing code: #!/usr/bin/perl use strict; use warnings; use feature 'say'; use Carp qw/croak carp/; use AnyEvent; use AnyEvent::Handle; use…
TheAthlete
  • 11
  • 1
1
vote
1 answer

Perl - Force LWP::Protocol subclass selection, or is there a better way?

Background: I've written an LWP::Protocol "implementor" for HTTP(S) based on AnyEvent::HTTP. (i.e: it implements both HTTP and HTTPS). It's different than LWP::Protocol::AnyEvent::http or Coro::LWP in that it doesn't BLOCK on $protocol->request.…
David-SkyMesh
  • 5,041
  • 1
  • 31
  • 38
1
vote
1 answer

Download M total files with N simultaneous Async HTTP clients, where M is large and N is configurable

I'm trying to write a script which will download at most N files simultaneously via HTTP. I've previously used AnyEvent::Worker::Pool to manage a pool of BLOCKING tasks. I've also used AnyEvent::HTTP in combination with AnyEvent->condvar to manage…
David-SkyMesh
  • 5,041
  • 1
  • 31
  • 38
1
vote
1 answer

Perl AnyEvent throwing HTTP Error 595

I have been trying to make asynchronous requests using Perl AnyEvent HTTP module with the following code. my $headers = { 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language'=>…
alpha_cod
  • 1,933
  • 5
  • 25
  • 43
1
vote
1 answer

Rewrite code from Threads to AnyEvent

I wrote a code: use LWP::UserAgent; use HTTP::Cookies; use threads; use threads::shared; $| = 1; $threads = 50; my @urls : shared = loadf('url.txt'); my @thread_list = (); $thread_list[$_] = threads->create(\&thread) for 0 .. $threads -…
user1779868
  • 101
  • 4
1
vote
3 answers

Running AnyEvent under Dancer application

I would like to do some non-blocking SSH to a couple of thousand machines that i'm tracking (my own machines), I have a Dancer application up and running, and I'm willing to use AnyEvent::timer to execute SSH commands asynchronously (each machine…
snoofkin
  • 8,725
  • 14
  • 49
  • 86
1
vote
1 answer

Perl AnyEvent::HTTP request using Proxy fails

I tried using the perl module AnyEvent::HTTP to make asynchronous HTTP requests by following this post: http://www.windley.com/archives/2012/03/asynchronous_http_requests_in_perl_using_anyevent.shtml However, I'm not able to get it working through…
alpha_cod
  • 1,933
  • 5
  • 25
  • 43
1
vote
3 answers

AnyEvent in multithreaded environment

I have that following subroutine, and have appx 20 threads calling it with different URLs (this sub belongs to a package, each thread calls a different instance of that package): sub get_urls { my ($self,$url,$depth) = @_; my $cv =…
snoofkin
  • 8,725
  • 14
  • 49
  • 86