Is there any way to use @async with SQLite.jl? The execution of a task only starts after the other one finishes in my tests.
function block_sql(n::Int64, tam::Int64)
local results = Channel(32);
local steps = convert(Int64, round(tam/n)) + 1
function do_work(i)
db = SQLite.DB(joinpath("data", "linksus.db"))
# Blocagem
println("Processo $i")
inicio = (i * steps) - steps
fim = i * steps
sql = """
SELECT
b1."index" as id1,
b2."index" as id2,
b1.nome as nome1,
b2.nome as nome2,
b1.nome_mae as nm_m1,
b2.nome_mae as nm_m2,
b1.dn as dn1,
b2.dn as dn2
from b1_proc as b1
inner join b2_proc as b2 on b2.dn = b1.dn or
(b2.sxpn = b1.sxpn and b2.sxun = b1.sxun and b2.sxpnm = b1.sxpnm and not b2.sxpnm is null) or
(b2.sxpn = b1.sxpn and b2.sxsn = b1.sxsn and b2.sexo = b1.sexo) or
(b2.sxun = b1.sxun and strftime('%Y',b2.dn) = strftime('%Y',b1.dn))
where
b1."index" >= $inicio and b1."index" <= $fim and
not b1."index" is null and not b2."index" is null
order by id1, id2
"""
df = DBInterface.execute(db, sql) |> DataFrame
show(df)
put!(results, (df))
end;
for i in 1:n # start 4 tasks to process requests in parallel
errormonitor(@async do_work(i))
# @async begin
# do_work(i)
# end
end
local stps = 2
@elapsed while stps > 0 # print out results
df = take!(results)
println(size(df, 1))
stps = stps - 1
end
end