flask-by-example icon indicating copy to clipboard operation
flask-by-example copied to clipboard

worker function not found

Open peetasan opened this issue 7 years ago • 5 comments

I am running the worker based on the README and get the following error after POSTing a url

$ python worker.py
22:45:34 RQ worker 'rq:worker:P6s-MacBook-Pro-2.33821' started, version 0.5.6
22:45:34
22:45:34 *** Listening on default...
22:45:46 default: __main__.count_and_save_words('http://index.hu') (aed5e21f-5b70-44c0-96d8-57845638cda0)
22:45:46 AttributeError: module '__main__' has no attribute 'count_and_save_words'
Traceback (most recent call last):
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/worker.py", line 568, in perform_job
    rv = job.perform()
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/job.py", line 206, in func
    return import_attribute(self.func_name)
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/utils.py", line 151, in import_attribute
    return getattr(module, attribute)
AttributeError: module '__main__' has no attribute 'count_and_save_words'
Traceback (most recent call last):
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/worker.py", line 568, in perform_job
    rv = job.perform()
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/job.py", line 206, in func
    return import_attribute(self.func_name)
  File "/Users/peetasan/dev/flask-by-example/virtualenv/lib/python3.6/site-packages/rq/utils.py", line 151, in import_attribute
    return getattr(module, attribute)
AttributeError: module '__main__' has no attribute 'count_and_save_words'
22:45:46 Moving job to 'failed' queue

peetasan avatar Jun 21 '17 20:06 peetasan

Which part of the tutorial are you in?

mjhea0 avatar Jun 22 '17 13:06 mjhea0

@mjhea0 I too experienced the same problem. Any hint?

QUDUSKUNLE avatar May 11 '18 17:05 QUDUSKUNLE

Same problem here.

dazzag24 avatar Jun 05 '18 14:06 dazzag24

Yeah same issue here.

caseybecking avatar Jun 21 '18 14:06 caseybecking

Redis also looks to be storing the information, it just looks wrong.

 1) "timeout"
 2) "180"
 3) "result_ttl"
 4) "5000"
 5) "status"
 6) "failed"
 7) "data"
 8) "\x80\x04\x95G\x00\x00\x00\x00\x00\x00\x00(\x8c\x1d__main__.count_and_save_words\x94N\x8c\x1bhttp://www.blackmonocle.com\x94\x85\x94}\x94t\x94."
 9) "exc_info"
10) "Traceback (most recent call last):\n  File \"/home/administrator/VM/flask-by-example/env/lib/python3.5/site-packages/rq/worker.py\", line 568, in perform_job\n    rv = job.perform()\n  File \"/home/administrator/VM/flask-by-example/env/lib/python3.5/site-packages/rq/job.py\", line 495, in perform\n    self._result = self.func(*self.args, **self.kwargs)\n  File \"/home/administrator/VM/flask-by-example/env/lib/python3.5/site-packages/rq/job.py\", line 206, in func\n    return import_attribute(self.func_name)\n  File \"/home/administrator/VM/flask-by-example/env/lib/python3.5/site-packages/rq/utils.py\", line 151, in import_attribute\n    return getattr(module, attribute)\nAttributeError: module '__main__' has no attribute 'count_and_save_words'\n"
11) "enqueued_at"
12) "2018-06-21T14:05:23Z"
13) "description"
14) "__main__.count_and_save_words('http://www.google.com')"
15) "origin"
16) "default"
17) "ended_at"
18) "2018-06-21T14:05:24Z"
19) "ttl"
20) "-1"
21) "created_at"
22) "2018-06-21T14:05:23Z"```

caseybecking avatar Jun 21 '18 14:06 caseybecking