Python timer 'NoneType' object is not callable error

JayGatsby

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 = response.read()
    text = data.decode('utf-8')
    if text == 'Hello World. Testing!':
        print("--Action Started!--")


t = Timer(10.0,listener('http://test.com/test.txt'))
t.start()

here is the output:

Status: Listening
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 1186, in run
    self.function(*self.args, **self.kwargs)
TypeError: 'NoneType' object is not callable

It runs the function for one time, after 10 seconds the error appears

miradulo

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python Error: TypeError: 'NoneType' object is not callable

From Dev

TypeError: 'NoneType' object is not callable python

From Dev

django 1.8 error: 'NoneType' object is not callable

From Dev

django 1.8 error: 'NoneType' object is not callable

From Dev

Django 1.10 error, 'NoneType' object is not callable

From Dev

Python class: TypeError: 'NoneType' object is not callable

From Dev

reverse(): 'NoneType' object is not callable

From Dev

TypeError: NoneType object is not callable

From Dev

reverse(): 'NoneType' object is not callable

From Dev

BeautifulSoup 'NoneType' object is not callable

From Dev

'int' object is not callable error in python

From Dev

Python error: 'dict' object is not callable

From Dev

Float Object is not Callable Error in Python

From Dev

'int' object is not callable error in python

From Dev

'NoneType' object is not callable beautifulsoup error while using get_text

From Dev

'NoneType' object is not callable beautifulsoup error while using get_text

From Dev

TypeError: 'NoneType' object is not callable(is ok in windows, but have this error in linux)

From Dev

TypeError: 'NoneType' object is not callable (Python: Scraping from HTML data)

From Dev

Python Facebook 'NoneType object error'

From Dev

Python Facebook 'NoneType object error'

From Dev

'NoneType' object is not callable' in BeautifulSoup findall()

From Dev

TypeError: 'NoneType' object is not callable, BeautifulSoup

From Dev

django-'NoneType' object is not callable

From Dev

NoneType object is not callable django admin

From Dev

Python Error: TypeError: 'list' object is not callable

From Dev

list() but 'str' object is not callable error in python

From Dev

SQLite/python: 'str' object is not callable error

From Dev

Python program error 'list' object is not callable

From Dev

'NoneType' object is not callable for an object that has a value?

Related Related

  1. 1

    Python Error: TypeError: 'NoneType' object is not callable

  2. 2

    TypeError: 'NoneType' object is not callable python

  3. 3

    django 1.8 error: 'NoneType' object is not callable

  4. 4

    django 1.8 error: 'NoneType' object is not callable

  5. 5

    Django 1.10 error, 'NoneType' object is not callable

  6. 6

    Python class: TypeError: 'NoneType' object is not callable

  7. 7

    reverse(): 'NoneType' object is not callable

  8. 8

    TypeError: NoneType object is not callable

  9. 9

    reverse(): 'NoneType' object is not callable

  10. 10

    BeautifulSoup 'NoneType' object is not callable

  11. 11

    'int' object is not callable error in python

  12. 12

    Python error: 'dict' object is not callable

  13. 13

    Float Object is not Callable Error in Python

  14. 14

    'int' object is not callable error in python

  15. 15

    'NoneType' object is not callable beautifulsoup error while using get_text

  16. 16

    'NoneType' object is not callable beautifulsoup error while using get_text

  17. 17

    TypeError: 'NoneType' object is not callable(is ok in windows, but have this error in linux)

  18. 18

    TypeError: 'NoneType' object is not callable (Python: Scraping from HTML data)

  19. 19

    Python Facebook 'NoneType object error'

  20. 20

    Python Facebook 'NoneType object error'

  21. 21

    'NoneType' object is not callable' in BeautifulSoup findall()

  22. 22

    TypeError: 'NoneType' object is not callable, BeautifulSoup

  23. 23

    django-'NoneType' object is not callable

  24. 24

    NoneType object is not callable django admin

  25. 25

    Python Error: TypeError: 'list' object is not callable

  26. 26

    list() but 'str' object is not callable error in python

  27. 27

    SQLite/python: 'str' object is not callable error

  28. 28

    Python program error 'list' object is not callable

  29. 29

    'NoneType' object is not callable for an object that has a value?

HotTag

Archive