Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I don't know why I missed your answer, but thanks again very much. Sorry it took me so long to respond.
Yes, there is a very specific reason why I want to create CPU affinity: I am using this script to launch multiple instances of an old single threaded application and each instance is going to be working on the same overall dataset, but the dataset is a collection of files, and I do not want any file clobbering. I am specifically and purposefully trying to eliminate any chance of one of these processes interfering (even just reading) the same file another process is currently working on.

Sorry if I seem to you to be asking basic questions - I am a plumber by trade...teaching oneself to code is very difficult.

I tried amending your example slightly to this - and it does not give the result I expect with regard to the $process values:

#!/usr/bin/perl use strict; use warnings; use 5.010; use Data::Dumper; use HTTP::Tiny; use Time::HiRes 'gettimeofday', 'tv_interval'; use MCE; use MCE::Shared; my $ua = HTTP::Tiny->new( timeout => 10 ); my @urls = qw< >; my $report = MCE::Shared->hash; my $process = MCE::Shared->scalar; $process = 0; MCE->new( max_workers => 6 )->foreach( \@urls, sub { my $start = [gettimeofday]; $process++; say $process."->GETting https://".$_; $ua->get('https://' . $_); $report->set( $_, tv_interval($start, [gettimeofday]) ); }); say Dumper $report->export;

The output reads:
1->GETting 1->GETting 1->GETting 1->GETting 1->GETting 1->GETting 2->GETting 2->GETting 2->GETting 3->GETting $VAR1 = bless( { '' => '1.15682', '' => '4.607657', '' => '0.46855', '' => '2.355818', '' => '1.170818', '' => '3.819699', '' => '1.479624', '' => '2.919818', '' => '2.540127', '' => '0.919592' }, 'MCE::Shared::Hash' );
whereas I had expected:
1->GETting 2->GETting 3->GETting 4->GETting 5->GETting 6->GETting 7->GETting 8->GETting 9->GETting 10->GETting $VAR1 = bless( { '' => '1.15682', '' => '4.607657', '' => '0.46855', '' => '2.355818', '' => '1.170818', '' => '3.819699', '' => '1.479624', '' => '2.919818', '' => '2.540127', '' => '0.919592' }, 'MCE::Shared::Hash' );

Can you explain this?


In reply to Re^6: Create parallel database handles... (MCE::Loop) by perlygapes
in thread Create parallel database handles or SQL statements for multi-threaded/process access to Postgres DB using DBI, DBD::Pg and Parallel::ForkManager by perlygapes

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (2)
    As of 2020-11-30 08:16 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found