Modern concurrency tools including agents, futures, promises, thread pools, supervisors, and more. Inspired by Erlang, Clojure, Scala, Go, Java, JavaScript, and classic concurrency patterns.
* Operating system: mac
* Ruby implementation: Ruby
* `concurrent-ruby` version: 1.1.0
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used: no
The following code goes into a mildly tight loop after hitting method/function (db_shim_watcher) once executed but doesn't honor the execution_interval...
...
...
...
def db_shim_watcher
tmp_queue = Queue.new
warn 'YES I GOT HERE!!' ## My debug statement for testing
# and just in case something changed since the the queue was emptied, we'll check it
# periodically here.
upd_resource_status if @watched_q.empty?
LOG.warn format(' checking db shim for updates: watched queue size currently: %<wq>s', { wq: @watched_q.size })
LOG.debug format(' processing queue objects in thread. @watched_q size is: %<wqs>s and tmp_queue size is: %<tqs>s', \
{ wqs: @watched_q.size, tqs: tmp_queue.size })
until @watched_q.empty?
@obj = @watched_q.pop
LOG.debug format(' -- a queued object popped; queue size now: %<wqs>s and tmp_queue size is: %<tqs>s',
{ wqs: @watched_q.size, tqs: tmp_queue.size })
tmp_queue = process_object(tmp_queue)
LOG.debug format(' -- tmp_queue.size is now: %<tqs>s', { tqs: tmp_queue.size })
status(@obj, @operator)
end
@watched_q = tmp_queue
LOG.warn format(' thread processed. @watched_q queue size now: %<wqs>s', { wqs: @watched_q.size })
end
# main entry point into running the operator
# @param [Void]
def run_oper
watcher = Concurrent::TimerTask.new(run_now: true, auto_terminate: true, execution_interval: 10) \
{ |task|
db_shim_watcher
}
watcher.execute
...
...
...
My output during a test run:
Note that between front of query_shim and at end lines are blocks of working code. There should be a period of 10 seconds between each succession. It's obviously not noticeable in this output, but the following has no time in between each iteration of run and it's as though the watcher never finishes its work because nothing in my code after executing the watcher gets reached.
at 23:27:39 ❯ clear && CR_LOG_LEVEL=INFO DB_SHIM_LOCAL_TEST=1 DB_SHIM_ADDR=http://localhost:8080 bin/console
qs 1 - front of query_shim
qs 2
qs 3
qs 5
qs 6
qs 8
ge 1
ge 2
ge 6
ge 7
ge 8
ge 9
qs 9
at end: @cr_obj is:
cc 1
cc 2
chc 4
hc 16 -- end
YES I GOT HERE!!
qs 1 - front of query_shim
qs 2
qs 3
qs 5
qs 6
qs 8
ge 1
ge 2
ge 6
ge 7
ge 8
ge 9
qs 1 - front of query_shim
qs 2
qs 9
at end: @cr_obj is:
cc 1
cc 2
chc 4
hc 16 -- end
qs 3
qs 5
qs 6
qs 8
ge 1
ge 2
ge 6
ge 7
ge 8
ge 9
qs 9
at end: @cr_obj is:
cc 1
cc 2
chc 4
hc 16 -- end
qs 1 - front of query_shim
...
...
...
The following code goes into a mildly tight loop after hitting method/function (
db_shim_watcher
) once executed but doesn't honor theexecution_interval
...My output during a test run:
Note that between
front of query_shim
andat end
lines are blocks of working code. There should be a period of 10 seconds between each succession. It's obviously not noticeable in this output, but the following has no time in between each iteration of run and it's as though thewatcher
never finishes its work because nothing in my code after executing thewatcher
gets reached.