Is there a simple way to do async in Perl? I have the following logic for an Apache app:
get request
process request
write to log
return
what I want to do is to have the “write to log” part to be async, so that I can do the “return” part asap.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, this typically entails the POE framework, but there is also a growing alternative (which I would want to try first) called AnyEvent.
See this question for learning materials for more information about learning POE. POE is a framework and it tends to eat your whole application. It also doesn’t look like Perl, and sticks out. I believe it is a big learning curve for your typical application.
AnyEvent is simple continuation based asyncronous tasking, you should be able to figure it out fairly well with just the CPAN docs.
For your specific question you would use AnyEvent’s AIO or POE’s Read Write wheel