We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
See this piece of code:
local threads = require 'threads' local parser = require("parser")["discounts"] local config = require("lapis.config").get() -- Returns paginator instance local paginator = function() local model = require("models")["discounts"] return model:paginated(model:query()) end -- Returns elasticsearch client local elasticsearch = function() local elasticsearch = require "elasticsearch" return elasticsearch.client{ hosts = config.elasticsearch.hosts } end local nthread = config.nthread local pages = paginator():num_pages() local pool = threads.Threads( nthread, function(threadid) paginated = paginator() client = elasticsearch() from_json = require("lapis.util").from_json es_type = paginated.model:table_name() print('starting a new thread/state number ' .. threadid) end ) local jobdone = 0 for i=1,pages do pool:addjob(function() local items = paginated:get_page(i) for i=1,#items do local data, err = client:index({ index = config.elasticsearch.index, type = es_type, id = items[i].id, body = parser(items[i]) }) end return __threadid end, function(id) jobdone = jobdone + 1 end) end pool:synchronize() print(string.format('%d jobs done', jobdone)) pool:terminate()
So, can i create another pool inside pool:addjob() ?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
See this piece of code:
So, can i create another pool inside pool:addjob() ?
The text was updated successfully, but these errors were encountered: