Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: creating unknown number of threads and then join results

by rudds_perl_habit (Novice)
on Jul 30, 2013 at 16:36 UTC ( [id://1047068]=note: print w/replies, xml ) Need Help??


in reply to Re: creating unknown number of threads and then join results
in thread creating unknown number of threads and then join results

Thanks for the suggestion about dumping the @results array. That did help. Well, sort of. It made me more confused, actually. In the find_thread routine, I added a line before the return:

print "find_thread dump $dir: " . Dumper(@results) . "\n";

I then run my script 10 times dumping the results to a 10 files. What I am finding is that the dump of @results can sometimes have output that is from another directory entirely. For example:

find_thread dump /vobs/doc: $VAR1 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/0'; $VAR2 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/1'; $VAR3 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/2'; $VAR4 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/3'; SIZE /vobs/doc: 4 find_thread dump /vobs/drs: $VAR1 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/0'; $VAR2 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/1'; $VAR3 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/2'; $VAR4 = '/vobs/license_manager/install/LMInstall/LM_Install.iap_xml@@/ +main/v4.0.0_gxp_patch/3'; SIZE /vobs/drs: 4

Which is totally confusing. @results is local to find_thread and shouldn't know anything about the other threads. What is even weirder is that when I switch to not use ClearCase find, and just find directories on the system, it seems to all work fine. So at this point, I am thinking that spawning multiple ClearCase find commands at once is causing an issue. I'll take it up with IBM.

Replies are listed 'Best First'.
Re^3: creating unknown number of threads and then join results
by BrowserUk (Patriarch) on Jul 30, 2013 at 18:32 UTC
    So at this point, I am thinking that spawning multiple ClearCase find commands at once is causing an issue. I'll take it up with IBM.

    I concur. There is nothing in your code that could account for the symptoms you are seeing, so their source can only lie with the commands you are calling.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I think I stumbled onto the answer. According to this article, the chdir command is not thread-safe. See http://www.perl.com/pub/2002/06/11/threads.html. See the section about 2/3 the way down titled "Altering Perls behavior to be thread-safe, ex::threads::cwd" . They give an example of how to "fix" it, too. In my script, I use "chdir" only if running the ClearCase commands, which explains why it is failing. I'll have to re-examine how I am doing that, or implement the fix in the article above.

        "Altering Perls behavior to be thread-safe, ex::threads::cwd" .

        Ah! That's a situation I've never encountered because Windows has an inherent notion of per-thread cwd.

        That is, chdir is threadsafe on windows where I do all my programming.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1047068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found