From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER,TVD_RCVD_IP shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: Out of band stuff? Date: Mon, 9 Apr 2012 03:05:52 +0000 Message-ID: <20120409030552.GA24089@dcvr.yhbt.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1333942065 31244 80.91.229.3 (9 Apr 2012 03:27:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 9 Apr 2012 03:27:45 +0000 (UTC) Cc: Damian Janowski To: Rainbows! list Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Mon Apr 09 05:27:41 2012 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Greylist: delayed 447 seconds by postgrey-1.31 at rubyforge; Mon, 09 Apr 2012 03:13:21 UTC Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:337 Archived-At: Received: from 50-56-192-79.static.cloud-ips.com ([50.56.192.79] helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SH5GW-0007VX-RC for gclrrg-rainbows-talk@m.gmane.org; Mon, 09 Apr 2012 05:27:40 +0200 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 21EF926302F; Mon, 9 Apr 2012 03:27:37 +0000 (UTC) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id C79C0263026 for ; Mon, 9 Apr 2012 03:13:21 +0000 (UTC) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 90DBE1F4E6; Mon, 9 Apr 2012 03:05:52 +0000 (UTC) Damian Janowski wrote: > Hello everyone, > > I'm needing to perform a couple of tasks outside of the request cycle. > For instance, I want to ping a web service every X minutes so that I > can maintain a persistent connection to it and have better response > times for some requests that I have to do *inside* the request cycle. > > What would be the reasonable way of doing this? For Raindrops::Watcher, I start a background thread on the first request: git clone git://bogomips.org/raindrops.git $EDITOR lib/raindrops/watcher.rb If you look at the `call' method in raindrops/watcher.rb, the important line is this: # @start is a Mutex and @thr is nil in the initialize method. @start.synchronize { @thr ||= aggregator_thread(env["rack.logger"]) } I avoid starting the background thread at initialization because it'll die on fork (meaning I'd have to recheck it all the time, anyways). The overhead of Mutex#synchronize and @thr||= assignment is negligible in most apps. > I'm thinking the OOB GC is just another example. But the current way > the OOB GC is written makes one think it's a very specific case and > not something one should use for other purposes. Yes, Unicorn::OobGC is very specific to how Unicorn works and the way it works wouldn't translate well to Rainbows! (as Rainbows! does persistent connections and unicorn does not). _______________________________________________ Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying