Skip to content

Commit 3163e3c

Browse files
Use Kernel.ParallelCompiler.pmap/2 instead of async/await (#433)
- Switch parallel PO compilation from async/await to pmap (requires Elixir ~> 1.16). - Remove unused put_locale guard and ensure_empty_msgstr!/1. - Move preferred_cli_env to cli/0 callback.
1 parent 05992bb commit 3163e3c

6 files changed

Lines changed: 11 additions & 21 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- os: ubuntu-22.04
2727
erlang: "24.2"
28-
elixir: "1.14"
28+
elixir: "1.16"
2929
env:
3030
MIX_ENV: test
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lib/gettext.ex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,6 @@ defmodule Gettext do
805805
@spec put_locale!(backend, locale) :: locale | nil
806806
def put_locale!(backend, locale) when is_binary(locale) do
807807
cond do
808-
not is_binary(locale) ->
809-
raise ArgumentError, "put_locale/2 only accepts binary locales, got: #{inspect(locale)}"
810-
811808
locale in known_locales(backend) ->
812809
put_locale(backend, locale)
813810

lib/gettext/compiler.ex

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,8 @@ defmodule Gettext.Compiler do
422422

423423
:parallel ->
424424
grouped
425-
|> Enum.map(fn {module, files} ->
426-
Kernel.ParallelCompiler.async(fn ->
427-
compile_split_po_files(env, module, files, plural_mod, opts[:interpolation])
428-
end)
429-
end)
430-
|> Enum.map(fn task ->
431-
Task.await(task, :infinity)
425+
|> Kernel.ParallelCompiler.pmap(fn {module, files} ->
426+
compile_split_po_files(env, module, files, plural_mod, opts[:interpolation])
432427
end)
433428
end
434429
end

lib/gettext/extractor.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,6 @@ defmodule Gettext.Extractor do
388388
end
389389
end
390390

391-
defp ensure_empty_msgstr!(%Message.Plural{} = message) do
392-
raise Error,
393-
"plural message with msgid '#{IO.iodata_to_binary(message.msgid)}' has a non-empty msgstr"
394-
end
395-
396391
defp blank?(str) when not is_nil(str), do: IO.iodata_length(str) == 0
397392
defp blank?(_), do: true
398393

mix.exs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ defmodule Gettext.Mixfile do
1010
[
1111
app: :gettext,
1212
version: @version,
13-
elixir: "~> 1.14",
13+
elixir: "~> 1.16",
1414
elixirc_paths: elixirc_paths(Mix.env()),
1515
build_embedded: Mix.env() == :prod,
1616
deps: deps(),
17-
preferred_cli_env: [coveralls: :test, "coveralls.html": :test, "coveralls.github": :test],
1817
test_coverage: [tool: ExCoveralls],
1918

2019
# Hex
@@ -45,6 +44,10 @@ defmodule Gettext.Mixfile do
4544
]
4645
end
4746

47+
def cli do
48+
[coveralls: :test, "coveralls.html": :test, "coveralls.github": :test]
49+
end
50+
4851
def application do
4952
[
5053
extra_applications: [:logger],

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
%{
22
"castore": {:hex, :castore, "1.0.10", "43bbeeac820f16c89f79721af1b3e092399b3a1ecc8df1a472738fd853574911", [:mix], [], "hexpm", "1b0b7ea14d889d9ea21202c43a4fa015eb913021cb535e8ed91946f4b77a8848"},
33
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
4-
"ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"},
4+
"ex_doc": {:hex, :ex_doc, "0.40.3", "4a972ffe64bc07dc605af487e98fc19b72a4185f55ca031b94c0552d6071c1d9", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2756e357742fecd9749b489b85d67c9ce99c465f2e75728d9e6dc8d704b973de"},
55
"excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"},
6-
"expo": {:hex, :expo, "1.1.0", "f7b9ed7fb5745ebe1eeedf3d6f29226c5dd52897ac67c0f8af62a07e661e5c75", [:mix], [], "hexpm", "fbadf93f4700fb44c331362177bdca9eeb8097e8b0ef525c9cc501cb9917c960"},
6+
"expo": {:hex, :expo, "1.1.1", "4202e1d2ca6e2b3b63e02f69cfe0a404f77702b041d02b58597c00992b601db5", [:mix], [], "hexpm", "5fb308b9cb359ae200b7e23d37c76978673aa1b06e2b3075d814ce12c5811640"},
77
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
88
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
99
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
10-
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
10+
"makeup_erlang": {:hex, :makeup_erlang, "1.1.0", "835f7e60792e08824cda445639555d7bf1bbbddb1b60b306e33cb6f6db24dc74", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "1cd6780fb1dd1a03979abaed0fe82712b0625118fd5257d3ebbf73f960c73c3c"},
1111
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
1212
}

0 commit comments

Comments
 (0)