parallel/concurrent process in python
minesh at gmail.com
Tue Mar 10 18:06:48 CET 2009
On Mon, Mar 9, 2009 at 2:47 PM, <Ommer.Simjee 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
# Do child stuff
More information about the Python-list