parallel/concurrent process in python

Ommer.Simjee at gmail.com Ommer.Simjee at gmail.com
Tue Mar 10 14:56:39 EDT 2009


On Mar 10, 10:06 am, Minesh Patel <min... at gmail.com> wrote:
> On Mon, Mar 9, 2009 at 2:47 PM,  <Ommer.Sim... at gmail.com> wrote:
> > I'm trying to figure out parallel process python code. Something
> > similar to fork funtion in C.
>
> > For example, I using sniff tool in scapy to capture packets but i want
> > this to run in the background:
>
> > -------
> > from scapy.all import *
> > import subprocess
> > import netsnmp
>
> > pkts=sniff(iface="eth0",filter="UDP",count=100) # This should run in
> > the background
>
> > print "Next Code."'
> > ---------
>
> > "Next Code." should be printed out right away and does not have to
> > wait for pkts=sniff(...) to finish.
>
> > Any ideas?
>
> Why not use os.fork(), it is the same as C's fork?
>
> if os.fork(): # Returns 0 to child, non-zero to parent
>   # Do parent stuff
> else:
>   # Do child stuff
>
> --
> Thanks,
> Minesh Patel

 Thanks,It works perfectly.



More information about the Python-list mailing list