Forum: Ruby multi process dont start a duplicate

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D974b374bd09edcef9285ff7c4f59ea5?d=identicon&s=25 Bigmac Turdsplash (i8igmac)
on 2014-03-12 05:20
list=["google", "yahoo","bing","facebook","msn","bigmac"]# user will
submit more every minute.

list.each{|domain|
   If not pid.exist("ping #{Domain}")
    Thread.start{ IO.popen("ping #{domain}")}
   End
}


I hope that explians what im trying to do...

prevent duplicate process from starting...

list.uniq is not a option. I'm looking for proces control...
0e6ac58dab6125c1cd2e7ac645076b6f?d=identicon&s=25 Joel VanderWerf (Guest)
on 2014-03-12 05:59
(Received via mailing list)
>     If not pid.exist("ping #{Domain}")

if not system "pgrep", "-f", cmdline
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (robert_k78)
on 2014-03-12 09:03
(Received via mailing list)
On Wed, Mar 12, 2014 at 5:20 AM, Bigmac Turdsplash
<lists@ruby-forum.com> wrote:
> I hope that explians what im trying to do...
>
> prevent duplicate process from starting...
>
> list.uniq is not a option. I'm looking for proces control...

What exactly are you trying to achieve?  From the looks of this it
sounds as if you want to have a constant stream of domain names as
input and ping each of them in parallel while preventing duplicate
pings to the same domain at the same time.  But what will be the
output of this?

Kind regards

robert
D974b374bd09edcef9285ff7c4f59ea5?d=identicon&s=25 Bigmac Turdsplash (i8igmac)
on 2014-03-12 15:19
Robert Klemme wrote in post #1139571:
> On Wed, Mar 12, 2014 at 5:20 AM, Bigmac Turdsplash
> <lists@ruby-forum.com> wrote:
>> I hope that explians what im trying to do...
>>
>> prevent duplicate process from starting...
>>
>> list.uniq is not a option. I'm looking for proces control...
>
> What exactly are you trying to achieve?  From the looks of this it
> sounds as if you want to have a constant stream of domain names as
> input and ping each of them in parallel while preventing duplicate
> pings to the same domain at the same time.  But what will be the
> output of this?
>
> Kind regards
>
> robert

If not Thread.exist("ping #{domain}")
   Thread.start{system("ping #{domain}")}
End

Maybe i need to learn how to check a list of running threads and block
threw them.
Or maybe the way to do this is with a global arry of domains_running
This topic is locked and can not be replied to.