Greetings all!
Anyway excuse my English.

I can't understand how I can do this:

<loop cycle; variable is filled by some values>
<loop is still running, but simultaneously another command is running>
<loop is terminated; i want to read variable>

More specifically (it concerned with Scapy module, but I'll explain the detailes):

# sniff() command reads packets from network interface in loop and puts them as list to variable 'a'
a = sniff()

# now I want sniff() to be running and to run another command - ping host
send(IP(dst='192.168.0.1')/ICMP())

# now I want to terminate sniff() loop and to see what in variable 'a'
print a

May be somebody who do parallel programming knows how I can do that?

I would use multiprocessing. See Doug Hellmann's "Signaling between processes with event objects" here. In multiprocessing, you can also use a dictionary or list to store a value. Some examples, plus see "shared namespaces" here. Start with running two processes and then add in the variable.

commented: good info +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.