Detached concurrent jobs#259
Conversation
File lib/Gitprep/Util.pm was in DOS format.
New subroutine command() supports options to set-up the child process environment and to specify standard file descriptos disposition. It returns a child control structure with various fields (pid, standard file descriptor pipe handles). Additional subroutines allow to operate on this structure to close pipes and to wait for child process end. Subroutine run_command() is rewritten to use this interface.
Signal SIGCHLD triggers the application event child_death: all captures of this signal should be made via this event. Warning: this is emitted asynchronously, so the same precautions as for an interrupt should be applied. The signal is set-up just before the url routing to avoid a Mojolicious use conflict (prefork, hypnotoad).
This package implements promise-based jobs that can be run asynchronously. Currently supports system commands and shell script execution. Full I/O stream concurrency is provided. An IOLoop-attached job queue is also featured.
This is a general fifo handler with event capabilities. Use it in the smart http service template.
Note that as of Net::Curl::Promiser version 0.20, these cannot be used in synchronous mode. The curl feature is currently unused.
This new package allows sending e-mails asynchronously either via a sendmail command or the smtp protocol using curl. the Email::Sender and associated MailTransport packages are no longer used. MailTransport smtp configuration parameters are translated to curl options and thus, no revolution occurs in gitprep.conf for this migration. The huge advantage of this solution compared to the previous one is the concurrency of actions: the http response may be sent while e-mails are not yet sent and several of the latter can be handled in parallel. Although an unlimited number of jobs can be queued, a maximum of 4 concurrent running jobs is currently hardcoded.
|
I'd like to take some time to think this over, as I want to make sure I fully grasp the technical complexities involved. |
|
I can document how it works if you need it. |
|
I'd like to go through this step-by-step to make sure I fully understand each part. |
|
The reason for using IPC::Open3 is to monitor file descriptors that involve both reading and writing, isn't it? |
|
Just a few hints:
|
Yes it is. Because the |
|
You mean it depends on libcurl, and I need to run an install command such as 'apt install libcurl4-openssl-dev' to install it? |
Yes, this is needed to compile |
|
Once the bugs in the dependent libraries are fixed, I am okay with merging the changes. SMTP/SMTPS : I understand that we can use libcurl's multi interface through Mojo::IOLoop and Net::Curl::Promisser for non-blocking operation. sendmail command: we use subprocess and IPC::Open3 for non-blocking operation . |
Thanks for your trust. I'm glad you like this new code.
Yes, that's it.
Right too, if you mean system subprocess and not It is possible however to use these new interfaces synchronously too and for something else than mail: see You may have noticed that |
|
BTW: Did you ever consider a way to patch external modules in your setup procedure? What are your thinking about it? |
If you mean patching the .xs or .c files included in distributions, I honestly can't think of an easy way to do that. As for .pm files, it is possible to apply monkey patches from GitPrep code at runtime for temporary fixes. If you have a specific approach in mind, I'm certainly open to including it in the setup procedure. |
Yes, this is what I mean. |
|
The only feasible workaround I can think of is to let cpanm run the installation first(using -n), and then manually re-install only the modules that require patching. However, if even using -n causes the compilation to fail, this approach wouldn't be applicable. |
|
Using your suggestion for our current case, the |
|
Another solution would be to download all packages and get the topological order (using deprecated |
|
Could you provide more details? I’m wondering, can we really determine all the necessary distributions and the correct installation order by using deprecated cpanm options? What are the deprecated cpanm options you're referring to? |
|
I have an idea: what if we manually pre-install only the distributions that require patching? Specifically, I could extract the tar.gz, move into the directory, run cpanm --installdeps . to fetch the dependencies, apply the patch, and then proceed with perl Makefile.PL && make && make test (or perl Build.PL ...), and make install |
|
I tried: Options |
They may require other packages. And you have to give them in the correct order. In addition, I would prefer a more automated solution. |
`cpanm --installdeps .' resolves that? |
Yes, but not between patched packages, if you have more than one. Thus it would be a dirty trick rather than an orthogonal process. That said, the commit for |
That’s true, but aren't patches really meant to be temporary, emergency fixes? Plus, if you need to apply patches to two different distributions, couldn't you just determine the order of dependencies and handle them accordingly? Don't you feel like writing your own installation script to handle CPAN dependency resolution is just too heavy of a task? |
They should But I'm afraid some PRs stay a long time before the maintainer considers and merges them. And I feel the one that blocks our changes falls in this category.
You mean manually ? This is highly error-prone, as an unsuspected third package may require the patched one without you even notice it.
I dont want to rewrite |
|
Rewriting the setup script in Perl is OK. |
|
Feel free to create a separate pull request for the dependency resolution and installation logic you have in mind. |
Hi Yuki,
Here is the code I plan to implement concurrent tasks.
It is highly based on promises and io loop scheduling and mainly consists of:
I tested it here successfully, but this is not ready to be merged, because of a bug in
Net::Curlawaiting a pending fix to be applied (sparky/perl-Net-Curl#87). I've investigated the way to local patching insetup_module, but unfortunatelycpanmis not able to do it. Any comment about your ideas on this is welcomed.There is another fix pending allowing
Net::Curl::Promiserto use a custom IO loop (FGasper/p5-Net-Curl-Promiser#4). This is optional yet, but will be needed to use curl synchronously.I make this PR a draft for the above reasons, but you can test it providing you fix
Net::Curlmanually.Regards,
Patrick