{"id":20315225,"url":"https://github.com/sysread/anyevent-processpool","last_synced_at":"2026-05-07T12:35:42.021Z","repository":{"id":56840439,"uuid":"97419005","full_name":"sysread/AnyEvent-ProcessPool","owner":"sysread","description":"An asynchronous process pool for Perl using AnyEvent","archived":false,"fork":false,"pushed_at":"2018-02-26T17:48:44.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T05:58:44.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysread.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-17T00:09:46.000Z","updated_at":"2017-11-12T22:43:56.000Z","dependencies_parsed_at":"2022-08-29T05:01:41.840Z","dependency_job_id":null,"html_url":"https://github.com/sysread/AnyEvent-ProcessPool","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FAnyEvent-ProcessPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FAnyEvent-ProcessPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FAnyEvent-ProcessPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FAnyEvent-ProcessPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysread","download_url":"https://codeload.github.com/sysread/AnyEvent-ProcessPool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241818877,"owners_count":20025210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T18:18:23.191Z","updated_at":"2026-05-07T12:35:41.992Z","avatar_url":"https://github.com/sysread.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"=pod\n\n=encoding UTF-8\n\n=head1 NAME\n\nAnyEvent::ProcessPool - Asynchronously runs code concurrently in a pool of perl processes\n\n=head1 VERSION\n\nversion 0.07\n\n=head1 SYNOPSIS\n\n  use AnyEvent::ProcessPool;\n\n  my $pool = AnyEvent::ProcessPool-\u003enew(\n    workers =\u003e 8,\n    limit   =\u003e 10,\n    include =\u003e ['lib', 'some/lib/path'],\n  );\n\n  my $condvar = $pool-\u003easync(sub{\n    # do task type stuff...\n  });\n\n  # Block until result is ready\n  my $result = $condvar-\u003erecv;\n\n=head1 DESCRIPTION\n\nExecutes code using a pool a forked Perl subprocesses. Supports configurable\npool size, automatically restarting processes after a configurable number of\nrequests, and closures (with the caveat that changes are not propagated back to\nthe parent process).\n\n=head1 CONSTRUCTOR\n\n=head2 workers\n\nRequired attribute specifying the number of worker processes to launch.\nDefaults to the number of CPUs.\n\n=head2 limit\n\nOptional attribute that causes a worker process to be restarted after\nperforming C\u003climit\u003e tasks. This can be useful when calling code which may be\nleaky. When unspecified or set to zero, worker processes will only be restarted\nif it unexpectedly fails.\n\n=head2 include\n\nAn optional array ref of paths to add to the perl command string used to start\nthe sub-process worker.\n\n=head1 METHODS\n\n=head2 async\n\nExecutes the supplied code ref in a worker sub-process. Remaining (optional)\narguments are passed unchanged to the code ref in the worker process. Returns a\nL\u003ccondvar|AnyEvent/CONDITION VARIABLES\u003e that will block and return the task\nresult when C\u003crecv\u003e is called on it.\n\nAlternately, the name of a task class may be supplied. The class must implement\nthe methods 'new' (as a constructor) and 'run'. When using a task class, the\narguments will be passed to the constructor (new) and the result of 'run' will\nbe returned.\n\n  # With an anonymous subroutine\n  my $cv = $pool-\u003easync(sub{ ... });\n\n  # With a code ref\n  my $cv = $pool-\u003easync(\\\u0026do_stuff);\n\n  # With optional parameter list\n  my $cv = $pool-\u003easync(sub{ ... }, $arg1, $arg2, ...);\n\n  # With a task class\n  my $cv = $pool-\u003easync('My::Task', $arg1, ...);\n\n=head2 join\n\nBlocks until all pending tasks have completed. This does not prevent new tasks\nfrom being queued while waiting (for example, in the callback of an already\nqueued task's condvar).\n\n=head1 PIPELINES\n\nPipelinelines are alternative way of using the process pool. See\nL\u003cAnyEvent::ProcessPool::Pipeline\u003e for details.\n\n  use AnyEvent::ProcessPool::Pipeline;\n\n  pipeline workers =\u003e 4,\n    in  { get_next_task() }\n    out { do_stuff_with_result(shift-\u003erecv) };\n\n=head1 DIAGNOSTICS\n\n=head2 Task errors\n\nError messages resulting from a C\u003cdie\u003e or C\u003ccroak\u003e in task code executed in a\nworker process are rethrown in the parent process when the condition variable's\nC\u003crecv\u003e method is called.\n\n=head2 \"AnyEvent::ProcessPool::Worker: ...\" (warning)\n\nWhen a worker sub-process emits output to C\u003cSTDERR\u003e, the process pool warns\nthe message out to its own C\u003cSTDERR\u003e.\n\n=head2 \"error launching worker process: ...\"\n\nThrown when a worker sub-process failed to launch due to an execution error.\n\n=head2 \"worker terminated in response to signal: ...\"\n\nThrown when a worker sub-process exits as a result of a signal received.\n\n=head2 \"worker terminated with non-zero exit status: ...\"\n\nThrown when a worker sub-process terminates with a non-zero exit code. The\nworker will be automatically restarted.\n\n=head1 INCOMPATIBILITIES\n\nWill not work on MSWin32 (although Cygwin should be fine) due to lack of\nsupport for non-blocking writes to process pipes (see notes in\nL\u003cAnyEvent::Open3::Simple\u003e.\n\n=head1 SEE ALSO\n\n=over\n\n=item L\u003cParallel::ForkManager\u003e\n\nHighly reliable, but somewhat arcane, blocking, and can be tricky to integrate\ninto non-blocking code.\n\n=item L\u003cCoro::ProcessPool\u003e\n\nSimilar in function, but runs only under L\u003cCoro\u003e (which as of 6.513 has\nexperimental support for 5.22).\n\n=back\n\n=head1 AUTHOR\n\nJeff Ober \u003csysread@fastmail.fm\u003e\n\n=head1 COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2018 by Jeff Ober.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n\n=cut\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fanyevent-processpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysread%2Fanyevent-processpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fanyevent-processpool/lists"}