I'm running the code below. From terminal I'm putting python test.py
. But it's giving me nothing.
###test.py### Version 2
from threading import Timer
def hello():
print "Hello"
t=Timer(5, hello)
t.start()
I tried the same code in a different machine, it's showing me the output properly. I tried going step by step. I kept only the print
statement and it's working fine. Then I added that print to a function, and called the function, it is also working fine. As soon as I add the Timer
, the python command keeps on running without showing any output, until I stop it by force.
Previously the same thing happened with scapy
library. But after a system restart it worked fine. But now it is not working after the system restart also.
What could be the problem?
Note 1: 6 days back, it was not behaving like this. Is there any chance of any malwares?
Note 2: A peculiar behaviour.
###test.py### Version 1
from threading import Timer
from time import sleep
def hello():
print "Hello"
t=Timer(5, hello)
t.start()
sleep(10)
This was my version 1. After it didn't work, I modified it to Version 2 which is mentioned above. Still no output. But when I press ctrl+c, It's showing
from time import sleep as _sleep
File .........., line 2, in <module>
KeyboardInterrupt
Though that line of code is not present there. I rechecked the saved file whether I saved or not. I also checked whether any pyc
file is creating trouble or not. But no pyc
was there.