Note that there are some explanatory texts on larger screens.

plurals
  1. POsidekiq not obeying loop logic
    primarykey
    data
    text
    <p>I have a "perform" method for sidekiq that runs perfectly when I'm not using a worker. It looks through each page and goes through each post. If a post is older than the "since_date", everything should stop. If it isn't, it will continue until there is no more data (current_page.any?). </p> <p>However, as soon as I turn on a worker to do the "perform" it doesn't obey my loop's logic to end. I initially had a break in there when my logic said to stop the loop and it worked fine. I thought maybe the "break" was causing the issue with the worker so I literally rewrote the entire function to not include "break". Turns out, it's still not obeying my logic. Here's my code:</p> <pre><code>begin current_page.each do |post| if Time.zone.parse(post["created_time"]) &lt; Time.zone.at(since_date.to_i) continue_loop = false else process_post(post) end end current_page = current_page.next_page if continue_loop end while current_page.any? &amp;&amp; continue_loop </code></pre> <p>basically this line:</p> <pre><code>if Time.zone.parse(post["created_time"]) &lt; Time.zone.at(since_date.to_i) </code></pre> <p>when it is true, everything should stop. however, the process continues until there is no more data (when current_page.any? is false). This leads me to believe there's maybe something wrong with how sidekiq works with Time?</p> <p>what am i doing wrong here?</p> <p>EDIT: I looked at the log file and it turns out sidekiq's worker thinks it's the year 1970 when doing Time.zone.at(since_date.to_i). But doing that without the worker reads the date just fine with the same value.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload