Forum: Ruby on Rails weired problem with periodically_call_remote

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
BENI (Guest)
on 2007-02-05 08:35
(Received via mailing list)
Can any one tell me why i get such large number of  POST messages to
the WEBBRICK...

It is crashing my WINDOWS within 5 minutes.


I am trying to make a portlet that will periodically refresh the stock
quotes. The quotes are arranged in atable and pulled from mysql
database .

I have a controller(mainpage_controller.rb)
=======
def index
@ticker_pages, @tickers = paginate :nsecurrent, :per_page => 20
end

=============
my view  layout(mainpage.rhtml)

<html>
<head>
  <title >TEST APPLICATION</title>

  <%= stylesheet_link_tag "list", :media => "all" %>
  <%= javascript_include_tag :defaults %>
<body>
<%= @content_for_layout %>
</body>
</html>
=================
my view ( index.rhtml)
<%= render :partial => "ticker_box",:layout => false %>
====================
my partial (_ticker_box.rhtml)

<%= periodically_call_remote( :update => "myinfobox",:frequency =>
60,:url => { :action => "index" } ) %>
<div id="myinfobox" class="update">
<h1 align="right" class="ListTitle2">Ticker Listing at <%= Time.now
%></h1>
<table align="right" cellpadding="3" cellspacing="2">
<tr valign="top" class="ListTitle0">
<td align="right"class="ListTitle2">TICKER</td>
<td align="right"class="ListTitle2">OPEN</td>
<td align="right"class="ListTitle2">HIGH</td>
<td align="right"class="ListTitle2">LOW</td>
<td align="right"class="ListTitle2">CURRENT</td>
</tr>

<%
odd_or_even = 0
for product in @tickers
 odd_or_even = 1 - odd_or_even
%>
<tr valign="top" class="ListLine<%= odd_or_even %>">
<td align="right"class="ListTitle0"><%=
h(product.symbol.slice(0,product.symbol.length-3)) %>
</td>
<td align="right"class="ListTitle0">
<%= product.open %>
</td>
<td align="right"class="ListTitle0">
<%= product.high %>
</td>
<td align="right"class="ListTitle0">
<%= product.low %>
</td>
<td align="right"class="ListTitle0">
<%= product.current_val %>
</td>
</tr>
<% end %>
</table>
</div>
===================

+++++++++++++++++++++++++++++++++++++++++++++++++

The strange webbrick log sequence

i started at 11:56:52

at 11:57:54 i got the first POST

at 11:58:54 & 11:58:55 I got 2 POST <<<<<<<<<<<<< WHY??????

at 11:59:54 , 11:59:55,11:59:55,11:59:55   i got 4 POST
<<<<<<<<<<<<<WHY?????

the log
============================

127.0.0.1 - - [05/Feb/2007:11:56:52 India Standard Time] "GET /
mainpage/ HTTP/1.1" 200 5892
- -> /mainpage/
127.0.0.1 - - [05/Feb/2007:11:57:54 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:58:54 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:58:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:59:54 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:59:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:59:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:11:59:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:54 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:55 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:56 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:56 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage
127.0.0.1 - - [05/Feb/2007:12:00:56 India Standard Time] "POST /
mainpage HTTP/1.1" 200 5892
- -> /mainpage

=================


Regards
Jordan K. (Guest)
on 2007-02-06 00:32
(Received via mailing list)
On 2/4/07, BENI <removed_email_address@domain.invalid> wrote:

> Can any one tell me why i get such large number of  POST messages to
> the WEBBRICK...

> i started at 11:56:52
> at 11:57:54 i got the first POST
> at 11:58:54 & 11:58:55 I got 2 POST <<<<<<<<<<<<< WHY??????
> at 11:59:54 , 11:59:55,11:59:55,11:59:55   i got 4 POST
> <<<<<<<<<<<<<WHY?????

As a programmer, upon seeing a doubling behaviour like this, you
should immediately have alarm bells going off in your head that scream
'recursion!'  Before even looking at your code, you should be able to
tell what the problem is based on the behaviour, but let's take a look
at the code anyway (snipped to show the relevant lines):

> my view ( index.rhtml)
> <%= render :partial => "ticker_box",:layout => false %>

> my partial (_ticker_box.rhtml)
> <%= periodically_call_remote( :update => "myinfobox",:frequency =>
> 60,:url => { :action => "index" } ) %>

index.rhtml is including a partial which updates part of the page with
index, which includes a partial, which updates part of its page with
index...  Can you see where this is going? :)  This is known as mutual
recursion.

> It is crashing my WINDOWS within 5 minutes.

Do you mean your browser windows?  After 5 minutes, it should still
only be around 2^4 requests -- if this is crashing Windows, you
probably have other issues with your OS.

HTH,

J.
BENI (Guest)
on 2007-02-06 07:39
(Received via mailing list)
Thanks I could get rid of the issue by putting the
periodically_call_remote in the index.rhtml .

Regards

r
This topic is locked and can not be replied to.