<commit_before>ambox = require('ambox')

function pstats(prefix)
  s = ambox.stats()
  for k, v in pairs(s) do print(prefix, k, v) end
end

p = print

function a1(timeout)
  local self_addr = ambox.self_addr()
  print("a1", self_addr, timeout)

  while true do
    local m = ambox.recv(nil, timeout)
    assert(m == 'timeout')
  end
end

a1_addr = ambox.spawn(a1, 2)

pstats("pre-cycle")
p("cycle returns", ambox.cycle())

pstats("pre-sleep")
os.execute('sleep 3')

p("cycle returns", ambox.cycle())

pstats("done")
p("DONE")<commit_msg>More timeout test<commit_after>ambox = require('ambox')

function pstats(prefix)
  s = ambox.stats()
  for k, v in pairs(s) do print(prefix, k, v) end
end

p = print

function a1(timeout)
  local self_addr = ambox.self_addr()
  print("a1", self_addr, timeout)

  while true do
    local m = ambox.recv(nil, timeout)
    assert(m == 'timeout')
  end
end

a1_addr = ambox.spawn(a1, 2)

pstats("pre-cycle")
t = ambox.cycle()
assert(t == 2)

pstats("pre-sleep")
os.execute('sleep 3')

t = ambox.cycle()
assert(t == 2)

pstats("pre-spawn")
a2_addr = ambox.spawn(a1, 2)

pstats("pre-sleep-more")
os.execute('sleep 3')

t = ambox.cycle()
assert(t == 2)

pstats("done")
p("DONE")
{'fraction_non_alphanumeric': 0.17135761589403972, 'fraction_numerical': 0.015728476821192054, 'mean_word_length': 4.349557522123894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6162572', 'n_tokens_mistral': 502, 'n_tokens_neox': 490, 'n_words': 120}