os.system vs os.system inside thread -> why is there any difference?
przemas_r at o2.pl
przemas_r at o2.pl
Wed Nov 17 12:43:42 EST 2004
Hello everybody.
I've found python's behaviour I can't understand. Namely the way
os.system () works depending if it's being run in Thread's run function
or run in 'normal' way.
>>> os.system ('arping -w 1 -c 1 -I eth1 192.168.0.2')
ARPING 192.168.0.2 from 62.233.239.115 eth1
Sent 1 probes (1 broadcast(s))
Received 0 response(s)
256
>>>
Here as you can see, arping command quits sending packets after 1 second
and outputs failure (Received 0 response(s)) information.
Now the same thing, but running from thread:
>>> class A (threading.Thread):
... def __init__ (self):
... threading.Thread.__init__ (self)
... def run (self):
... os.system ('arping -w 1 -c 1 -I eth1 192.168.0.2')
...
>>> A ().start ()
>>> ARPING 192.168.0.2 from 62.233.239.115 eth1
<lots of time and nothing happens>
Now, although the only difference is that command arping is being run in
thread, command never quits, informing about it's failure (-w 1 switch
means that it should quit in 1 second). Mistery.
Please help me if you know what's going on.
--
Przemysław Różycki
More information about the Python-list
mailing list