{"id":20315243,"url":"https://github.com/sysread/proc-tored-pool","last_synced_at":"2026-05-29T08:04:23.697Z","repository":{"id":56839310,"uuid":"82109686","full_name":"sysread/Proc-tored-Pool","owner":"sysread","description":"Managed worker pool with Proc::tored and Parallel::ForkManager","archived":false,"fork":false,"pushed_at":"2017-03-20T19:10:10.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T05:58:45.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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-02-15T21:39:58.000Z","updated_at":"2017-02-16T14:02:46.000Z","dependencies_parsed_at":"2022-08-29T04:52:40.221Z","dependency_job_id":null,"html_url":"https://github.com/sysread/Proc-tored-Pool","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FProc-tored-Pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FProc-tored-Pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FProc-tored-Pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FProc-tored-Pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysread","download_url":"https://codeload.github.com/sysread/Proc-tored-Pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241818872,"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:28.812Z","updated_at":"2025-12-12T02:44:10.215Z","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\nProc::tored::Pool - managed work pool with Proc::tored and Parallel::ForkManager\n\n=head1 VERSION\n\nversion 0.08\n\n=head1 SYNOPSIS\n\n  use Proc::tored::Pool;\n\n  # Create a worker pool service\n  my $pool = pool 'thing-doer', in '/var/run', capacity 10,\n    on success, call {\n      my ($me, $id, @results) = @_;\n      print \"thing $id complete: @results\";\n    },\n    on failure, call {\n      my ($me, $id, $message) = @_;\n      warn \"thing $id failed: $message\";\n    };\n\n  # Do things with the pool\n  run {\n    my ($thing_id, $thing) = get_next_thing();\n    process { do_things($thing) } $pool, $thing_id;\n  } $pool;\n\n  # Control the pool as a Proc::tored service\n  pause $pool;\n  resume $pool;\n  stop $pool;\n  zap $pool, 15 or die \"timed out after 15 seconds waiting for pool to stop\";\n  start $pool;\n\n=head1 DESCRIPTION\n\nProvides a simple and fast interfact to build and manage a pool of forked\nworker processes. The process is controlled using a pidfile and touch file.\n\n=head1 EXPORTED SUBROUTINES\n\nAs a C\u003cProc::tored::Pool\u003e is a L\u003cProc::tored\u003e service, it by default exports\nthe same functions as L\u003cProc::tored/EXPORTED SUBROUTINES\u003e.\n\nIn addition, the following subroutines are exported by default.\n\n=head2 pool\n\nCreates the pool (an instance of L\u003cProc::tored::Pool::Manager\u003e). Requires a\nC\u003c$name\u003e as its first argument.\n\n  my $pool = pool 'the-proletariat', ...;\n\n=head2 capacity\n\nSets the max number of forked worker processes to be permitted at any given\ntime.\n\n  my $pool = pool 'the-proletariat', capacity 16, ...;\n\n=head2 on\n\nBuilds an event callback with one of L\u003c/assignment\u003e, L\u003c/success\u003e, or L\u003c/failure\u003e.\n\n  my $pool = pool 'the-proletariat', capacity 16,\n    on success, call { ... };\n\n=head2 call\n\nDefines the code to be called by an event callback. See L\u003c/on\u003e.\n\n=head2 pending\n\nReturns the number of tasks that have been assigned to worker processes but\nhave not yet completed.\n\n=head2 process\n\nSends a task (a C\u003cCODE\u003e ref) to the pool, optionally specifying a task id to\nidentify the results in callbacks. The return value of the supplied code ref is\npassed as is to the L\u003c/success\u003e callback (if supplied).\n\n  process { seize_the_means_of_production() } $pool;\n  process { seize_the_means_of_production() } $pool, $task_id;\n\n=head2 sync\n\nFor situations in which a task or tasks must be completed before program\nexecution can continue, C\u003csync\u003e may be used to block until all pending tasks\nhave completed. After calling sync, there will be no pending tasks and all\ncallbacks for previously submitted tasks will have been called.\n\n  process { seize_the_means_of_production() } $pool;\n  sync $pool;\n\n=head1 EVENTS\n\n=head2 assignment\n\nTriggered immediately after a task is assigned to a worker process. Receives\nthe pool object and the task id (if provided when calling L\u003c/pool\u003e).\n\n  my $pool = pool 'thing-doer', ...,\n    on assignment, call {\n      my ($self, $task_id) = @_;\n      $assigned{$task_id} = 1;\n    };\n\n  process { do_things() } $pool, $task_id;\n\n=head2 success\n\nTriggered after the completion of a task. Receives the pool object, task id (if\nprovided when calling L\u003c/pool\u003e), and the return value of the code block.\n\n  my $pool = pool 'thing-doer', ...,\n    on success, call {\n      my ($self, $task_id, @results) = @_;\n      ...\n    };\n\n  process { do_things() } $pool, $task_id;\n\nIf L\u003c/process\u003e performs an C\u003cexec\u003e, no data is returned from the worker process\n(because C\u003cexec\u003e never returns). In this case, if the process had a zero exit\nstatus, the C\u003csuccess\u003e callback is triggered with the results value of C\u003c\"zero\nbut true\"\u003e. A non-zero exit status is handled by C\u003cfailure\u003e as in the general\ncase.\n\n=head2 failure\n\nTriggered if the code block dies or the forked worker exits abnormally.\nRecieves the pool object, task id (if provided when calling L\u003c/pool\u003e), and the\nerror message generated by the code ref.\n\n  my $pool = pool 'thing-doer', ...,\n    on failure, call {\n      my ($self, $task_id, $error) = @_;\n      warn \"Error executing task $task_id: $error\";\n    };\n\n  process { do_things() } $pool, $task_id;\n\n=head1 BUGS AND LIMITATIONS\n\n=head2 Proc::tored\n\nWarnings and limitations for L\u003cProc::tored\u003e also apply to this module,\nespecially the notes regarding service control from within a running service\nwhich also apply to code executing in forked worker processes. See\nL\u003cProc::tored/BUGS AND LIMITATIONS\u003e for details.\n\n=head2 Parallel::ForkManager\n\nWarnings and limitations for L\u003cParallel::ForkManager\u003e also apply to this\nmodule, including the injunction against using two pools simultaneously from\nthe same process. See L\u003cParallel::ForkManager/BUGS AND LIMITATIONS\u003e and\nL\u003cParallel::ForkManager/SECURITY\u003e for details.\n\n=head1 SEE ALSO\n\n=over\n\n=item L\u003cProc::tored\u003e\n\n=item L\u003cParallel::ForkManager\u003e\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) 2017 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%2Fproc-tored-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysread%2Fproc-tored-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fproc-tored-pool/lists"}