Python Timer 'nonetype' Object Is Not Callable Error
I want to make a program which is checks the given url for every 10 seconds def listener(url): print ('Status: Listening') response = urllib.request.urlopen(url) data =
Solution 1:
Currently, the result of your listener
function call is being given to Timer
, which is resultantly None
, as you need to make an explicit return so your Timer
has something to operate on.
You have to place the argument for your listener()
in another parameter, like this. Note that args
must be a sequence, thus the tuple with the comma placed after your url
. Without this tuple, you are passing each individual character from 'http://test.com/test.txt'
as an argument to listener
.
t = Timer(10.0,listener,args=('http://test.com/test.txt',))
As you can see in documentation here, arguments must be passed as a third parameter.
Post a Comment for "Python Timer 'nonetype' Object Is Not Callable Error"