Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: Inline::Java with MCE::Hobo

by eraskin (Novice)
on May 27, 2021 at 15:06 UTC ( #11133139=note: print w/replies, xml ) Need Help??

in reply to Re: Inline::Java with MCE::Hobo
in thread Inline::Java with MCE::Hobo

I could not make the require work. First, I removed the "use SexCoder" from the top of my script. Then I added this:

MCE::Hobo->init(on_start => sub { require SexCoder; });
The error message I got was:
Hobo 30016 terminated abnormally: reason Can't locate object method "n +ew" via package "SexCoder" (perhaps you forgot to load "SexCoder"?) a +t ./convert.mce line 721, <__ANONIO__> line 24.

So, the SexCoder did not load. I then tried removing the Hobo->init and placing "use SexCoder" inside my worker sub {}. That was no different than my original code. I had exactly the same issue, where some workers were able to get results from the service and others were not. That really confuses me. I think you are on the right track, though. There must be something odd in my SexCoder package that I'm not seeing. See my reply to cavac above for the complete code to that package. Maybe you can see something?

I have one more tidbit for everyone helping me. The code works if $num_workers = 1 (simulating single-threaded code). That's why I suspect an issue with Inline::Java or with the rtsClient itself. I just can't fathom why if each is running in its own process.

Replies are listed 'Best First'.
Re^3: Inline::Java with MCE::Hobo
by Anonymous Monk on Jul 24, 2021 at 05:32 UTC

    Greetings eraskin,

    Have you tried importing SexCoder inside the input_task Hobo routine. This is where to load the class uniquely per worker child.

    sub input_task { require SexCoder; SexCoder->import(); # THIS CALLS JAVA TO CREATE THE CONNECTION TO DATA SERVICES my $sexcoder = SexCoder->new("$ds_server", 4000); ... }

      Kind reminder: Remember to comment out SexCoder at the top of the script to ensure the class is loaded by each Hobo worker individually.

      my $num_workers = 5; # use SexCoder; use MCE::Hobo; use MCE::Shared; ...

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-10-21 11:36 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (83 votes). Check out past polls.