Re: POE and perl fork interaction

2009-01-15 Thread douglasstvnsn

 Deven,

Take a look at the Cookbook and the job control examples.

While a poe kernel is a process singleton, you can have many sessions running 
on the same kernel.


 
Dougie!!!


 

-Original Message-
From: Deven Parekh 
To: [email protected]
Cc: [email protected]; [email protected]
Sent: Thu, 15 Jan 2009 10:35 am
Subject: Re: POE and perl fork interaction










Hello Rob, Dougie,

Thanks for the suggestion. I apologize for not being clear on what i am
trying to achieve.
Basically I have built a wrapper module around POE to handle certain tasks.
This allows
the user of the wrapper module to be ignorant about POE. Each task has its
own wrapper
module and interface.

examples of task is
- tailig of files,  has its own set of wrapper module
- placing a test VOIP call to VOIP server under test,  has its own set of
wrapper module
- verifying contents in tailed files,  has it own set of wrapper module

I want each of these to be independent POE wrappers and an independent way
to start/stop each of the task. I have POE::Kernel->run per set of wrapper
modules
that starts of the task.

I tried to create a set of wrapper module for the file tailing using
POE::Component::IKC
POE::Wheel::FollowTail (i wanted to tail files on remote machines, so also
looked
at POE::Componenet::RemoteTail)
POE::Wheel::Run

But since POE::Kernel is a singleton per process when i have a script
that is trying to launch multiple task (implying multiple sets of wrappers)
there is lot of interaction and the kernels don't seem to stop since
(I am assuming the kernel resources/state get all mixed up due to the way i
have
it coded).

But both your comments about "...start another kernel on that process" and
"POE::Wheel::Run ... Nested POE Kernels" seem to be interesting. i will
explore that
option. Any additional pointers to these topics?

In the mean time if you have suggestion on how i can achieve the above
i will aprreciate it.

I know it is difficult to provide input based just on pure white-paper text
as above
instead of looking at code samples and ruuning example outputs.

Regards
Deven.
p.s: For my problem of using perl's fork and POE in the same script I turned
on
  some debugging on POE::Kernel and observed that there may be some
  interaction with handling the "CHLD" signal. All the sessions in
POE::Kernel
  terminate succesfully and there are no resources in use, except the
POE::Kernel
  seems to some how wait for the forked child  (that happen outside of
POE::Kernel)
  to finish. Once those forked child process are done (killed) the
POE::Kernel seems
  to retrun.  I am not sure how/why POE::Kernel gets a signal handler
registered to
  keep waiting for process forked outside of it. I had forked those
process before
  running the POE::Kernel.




On Wed, Jan 14, 2009 at 11:40 AM,  wrote:

>
> This got me to thinking
>
> Setup a POE::Wheel::Followtail for each  file you want to tail.  No need
> to spawn off other processes.
>
> If you DO need separate processes, from the main process run a
> POE::Wheel::Run and start another kernel on that process.  Setup a
> Followtail wheel for the input and handle the output back to the Main code
> via STDOUT and the Run object.
>
> I tend to use fork sparingly and if you need to do alot of things
> simultaneously, you should probably handle those in POE first.
>
> HTH,
>
> Dougie!!!
>
> -Original Message-
> From: Robert Landrum 
> To: Deven Parekh 
> Cc: [email protected]
> Sent: Tue, 13 Jan 2009 6:51 pm
> Subject: Re: POE and perl fork interaction
>
> It's not clear what you're trying to do, but I suspect that you're doing it
> wrong. :(
>
> Is there a reason why you don't use POE::Wheel::Run to tail the files?
>
> There's also:
>
> http://search.cpan.org/~rcaputo/POE-1.003/lib/POE/Wheel/FollowTail.pm
>
> I suspect that your forked tail process may have events queued from the
> parent, as outlined in POE::Wheel::Run section on Nested POE Kernels.
>
> Good luck.
>
> Rob
>
> Deven Parekh wrote:
> > Hello,
> >
> > Is it possible to use POE and the fork function in the same script.
> > I am running into an interaction problem where the POE::Kernel does not
> > return if i have forked off other process outside of the POE. Any input
> on
> > what I may be doing wrong
> >
> > Here is the psuedo code logic of my script
> >
> > #--- Call a function to fork off a process to start tailing some files
> > #--- store its the above pids so we can terminate later
> >
> > #--- Call POE::Wheel::Run to do some task
> >
> > #--- After the above POE task returns kill the tailing process
> >
> >
> > If i do not do the forking for tailing files, the P

Re: POE and perl fork interaction

2009-01-15 Thread Deven Parekh
Hello Rob, Dougie,

Thanks for the suggestion. I apologize for not being clear on what i am
trying to achieve.
Basically I have built a wrapper module around POE to handle certain tasks.
This allows
the user of the wrapper module to be ignorant about POE. Each task has its
own wrapper
module and interface.

examples of task is
- tailig of files,  has its own set of wrapper module
- placing a test VOIP call to VOIP server under test,  has its own set of
wrapper module
- verifying contents in tailed files,  has it own set of wrapper module

I want each of these to be independent POE wrappers and an independent way
to start/stop each of the task. I have POE::Kernel->run per set of wrapper
modules
that starts of the task.

I tried to create a set of wrapper module for the file tailing using
POE::Component::IKC
POE::Wheel::FollowTail (i wanted to tail files on remote machines, so also
looked
at POE::Componenet::RemoteTail)
POE::Wheel::Run

But since POE::Kernel is a singleton per process when i have a script
that is trying to launch multiple task (implying multiple sets of wrappers)
there is lot of interaction and the kernels don't seem to stop since
(I am assuming the kernel resources/state get all mixed up due to the way i
have
it coded).

But both your comments about "...start another kernel on that process" and
"POE::Wheel::Run ... Nested POE Kernels" seem to be interesting. i will
explore that
option. Any additional pointers to these topics?

In the mean time if you have suggestion on how i can achieve the above
i will aprreciate it.

I know it is difficult to provide input based just on pure white-paper text
as above
instead of looking at code samples and ruuning example outputs.

Regards
Deven.
p.s: For my problem of using perl's fork and POE in the same script I turned
on
  some debugging on POE::Kernel and observed that there may be some
  interaction with handling the "CHLD" signal. All the sessions in
POE::Kernel
  terminate succesfully and there are no resources in use, except the
POE::Kernel
  seems to some how wait for the forked child  (that happen outside of
POE::Kernel)
  to finish. Once those forked child process are done (killed) the
POE::Kernel seems
  to retrun.  I am not sure how/why POE::Kernel gets a signal handler
registered to
  keep waiting for process forked outside of it. I had forked those
process before
  running the POE::Kernel.




On Wed, Jan 14, 2009 at 11:40 AM,  wrote:

>
> This got me to thinking
>
> Setup a POE::Wheel::Followtail for each  file you want to tail.  No need
> to spawn off other processes.
>
> If you DO need separate processes, from the main process run a
> POE::Wheel::Run and start another kernel on that process.  Setup a
> Followtail wheel for the input and handle the output back to the Main code
> via STDOUT and the Run object.
>
> I tend to use fork sparingly and if you need to do alot of things
> simultaneously, you should probably handle those in POE first.
>
> HTH,
>
> Dougie!!!
>
> -Original Message-
> From: Robert Landrum 
> To: Deven Parekh 
> Cc: [email protected]
> Sent: Tue, 13 Jan 2009 6:51 pm
> Subject: Re: POE and perl fork interaction
>
> It's not clear what you're trying to do, but I suspect that you're doing it
> wrong. :(
>
> Is there a reason why you don't use POE::Wheel::Run to tail the files?
>
> There's also:
>
> http://search.cpan.org/~rcaputo/POE-1.003/lib/POE/Wheel/FollowTail.pm
>
> I suspect that your forked tail process may have events queued from the
> parent, as outlined in POE::Wheel::Run section on Nested POE Kernels.
>
> Good luck.
>
> Rob
>
> Deven Parekh wrote:
> > Hello,
> >
> > Is it possible to use POE and the fork function in the same script.
> > I am running into an interaction problem where the POE::Kernel does not
> > return if i have forked off other process outside of the POE. Any input
> on
> > what I may be doing wrong
> >
> > Here is the psuedo code logic of my script
> >
> > #--- Call a function to fork off a process to start tailing some files
> > #--- store its the above pids so we can terminate later
> >
> > #--- Call POE::Wheel::Run to do some task
> >
> > #--- After the above POE task returns kill the tailing process
> >
> >
> > If i do not do the forking for tailing files, the POE::Kernel returns
> after
> > the
> > task is completed, but if I fork of the tailing process as above,
> > the POE::Kernel never returns.
> >
> > Any input will be appreciated.
> >
> > Thanks in advance.
> >
> > BR
> > DP
> > p.s: I thought i had read about this interaction somewhere in
> documentation
> > but am not
> > able toget to it to follow discussion around it, if any.
> >
> >
>
> --
> Which stars will make the biggest headlines in 2009? Get Hollywood
> predictions, celebrity holiday photos and more with the PopEater 
> Toolbar<http://toolbar.aol.com/popeater/download.html?ncid=emlweusdown0025>.
>
>


Re: POE and perl fork interaction

2009-01-14 Thread douglasstvnsn




 This got me to thinking

Setup a POE::Wheel::Followtail for each? file you want to tail.? No need to 
spawn off other processes.

If you DO need separate processes, from the main process run a POE::Wheel::Run 
and start another kernel on that process.? Setup a Followtail wheel for the 
input and handle the output back to the Main code via STDOUT and the Run object.

I tend to use fork sparingly and if you need to do alot of things 
simultaneously, you should probably handle those in POE first.

HTH,

Dougie!!!


 

-Original Message-
From: Robert Landrum 
To: Deven Parekh 
Cc: [email protected]
Sent: Tue, 13 Jan 2009 6:51 pm
Subject: Re: POE and perl fork interaction









It's not clear what you're trying to do, but I suspect that you're doing 
it wrong.  :(?
?

Is there a reason why you don't use POE::Wheel::Run to tail the files??
?

There's also:?
?

http://search.cpan.org/~rcaputo/POE-1.003/lib/POE/Wheel/FollowTail.pm?
?

I suspect that your forked tail process may have events queued from the 
parent, as outlined in POE::Wheel::Run section on Nested POE Kernels.?
?

Good luck.?
?

Rob?
?


Deven Parekh wrote:?

> Hello,?

>?

> Is it possible to use POE and the fork function in the same script.?

> I am running into an interaction problem where the POE::Kernel does not?

> return if i have forked off other process outside of the POE. Any input on?

> what I may be doing wrong?

>?

> Here is the psuedo code logic of my script?

>?

> #--- Call a function to fork off a process to start tailing some files?

> #--- store its the above pids so we can terminate later?

>?

> #--- Call POE::Wheel::Run to do some task?

>?

> #--- After the above POE task returns kill the tailing process?

>?

>?

> If i do not do the forking for tailing files, the POE::Kernel returns after?

> the?

> task is completed, but if I fork of the tailing process as above,?

> the POE::Kernel never returns.?

>?

> Any input will be appreciated.?

>?

> Thanks in advance.?

>?

> BR?

>   DP?

> p.s: I thought i had read about this interaction somewhere in documentation?

> but am not?

>   able toget to it to follow discussion around it, if any.?

>?

>   ?



 



Re: POE and perl fork interaction

2009-01-14 Thread Robert Landrum
It's not clear what you're trying to do, but I suspect that you're doing 
it wrong.  :(


Is there a reason why you don't use POE::Wheel::Run to tail the files?

There's also:

http://search.cpan.org/~rcaputo/POE-1.003/lib/POE/Wheel/FollowTail.pm

I suspect that your forked tail process may have events queued from the 
parent, as outlined in POE::Wheel::Run section on Nested POE Kernels.


Good luck.

Rob


Deven Parekh wrote:

Hello,

Is it possible to use POE and the fork function in the same script.
I am running into an interaction problem where the POE::Kernel does not
return if i have forked off other process outside of the POE. Any input on
what I may be doing wrong

Here is the psuedo code logic of my script

#--- Call a function to fork off a process to start tailing some files
#--- store its the above pids so we can terminate later

#--- Call POE::Wheel::Run to do some task

#--- After the above POE task returns kill the tailing process


If i do not do the forking for tailing files, the POE::Kernel returns after
the
task is completed, but if I fork of the tailing process as above,
the POE::Kernel never returns.

Any input will be appreciated.

Thanks in advance.

BR
  DP
p.s: I thought i had read about this interaction somewhere in documentation
but am not
  able toget to it to follow discussion around it, if any.