Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activating invalid egg doesn't raise helpful exception #282

Closed
StrikerUnit opened this issue May 15, 2018 · 5 comments
Closed

Activating invalid egg doesn't raise helpful exception #282

StrikerUnit opened this issue May 15, 2018 · 5 comments

Comments

@StrikerUnit
Copy link

StrikerUnit commented May 15, 2018

Hi,

I just start using Scrapy, found this error and don't know how to fix this.

Python 3.6.5 :: Anaconda custom (x86_64)

	Traceback (most recent call last):
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/twisted/web/http.py", line 2145, in allContentReceived
	    req.requestReceived(command, path, version)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/twisted/web/http.py", line 890, in requestReceived
	    self.process()
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/twisted/web/server.py", line 197, in process
	    self.render(resrc)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/twisted/web/server.py", line 257, in render
	    body = resrc.render(self)
	--- <exception caught here> ---
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/webservice.py", line 21, in render
	    return JsonResource.render(self, txrequest).encode('utf-8')
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/utils.py", line 20, in render
	    r = resource.Resource.render(self, txrequest)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/twisted/web/resource.py", line 250, in render
	    return m(request)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/webservice.py", line 86, in render_POST
	    spiders = get_spider_list(project, version=version)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/utils.py", line 137, in get_spider_list
	    raise RuntimeError(msg.encode('unicode_escape') if six.PY2 else msg)
	builtins.RuntimeError: Traceback (most recent call last):
	  File "/Users/homerun/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
	    "__main__", mod_spec)
	  File "/Users/homerun/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
	    exec(code, run_globals)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/runner.py", line 40, in <module>
	    main()
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/runner.py", line 35, in main
	    with project_environment(project):
	  File "/Users/homerun/anaconda3/lib/python3.6/contextlib.py", line 81, in __enter__
	    return next(self.gen)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/runner.py", line 23, in project_environment
	    activate_egg(eggpath)
	  File "/Users/homerun/anaconda3/lib/python3.6/site-packages/scrapyd/eggutils.py", line 9, in activate_egg
	    d = next(pkg_resources.find_distributions(eggpath))
	TypeError: 'tuple' object is not an iterator
@riklaunim
Copy link

Same with Python 3.7 right now. Latest scrapy and scrapyd. Created scrapy project, then a black spider, made an egg with setup.py bdist_egg to then call
curl http://localhost:6800/addversion.json -F project=projekt -F version=r1 -F egg=dist/projekt-0.1-py3.7.egg
within a virtualenv with scrapy/scrapyd etc.

@my8100
Copy link
Collaborator

my8100 commented Jul 15, 2019

@riklaunim
There should be an @ sign: -F egg=@dist/projekt-0.1-py3.7.egg

@riklaunim
Copy link

oh, nice. That works.

@my8100
Copy link
Collaborator

my8100 commented Jul 15, 2019

With -F egg=dist/project-1.0-py3.7.egg

curl http://localhost:6800/addversion.json -F project=myproject -F version=r1 -F egg=dist/project-1.0-py3.7.egg
{"node_name": "ubuntu", "status": "error", "message": "Traceback (most recent call last):\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\n    \"__main__\", mod_spec)\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/site-packages/scrapyd/runner.py\", line 40, in <module>\n    main()\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/site-packages/scrapyd/runner.py\", line 35, in main\n    with project_environment(project):\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/contextlib.py\", line 112, in __enter__\n    return next(self.gen)\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/site-packages/scrapyd/runner.py\", line 23, in project_environment\n    activate_egg(eggpath)\n  File \"/home/ubuntu/anaconda3/envs/py3/lib/python3.7/site-packages/scrapyd/eggutils.py\", line 9, in activate_egg\n    d = next(pkg_resources.find_distributions(eggpath))\nTypeError: 'tuple' object is not an iterator\n"}

With -F egg=@dist/project-1.0-py3.7.egg

curl http://localhost:6800/addversion.json -F project=myproject -F version=r1 -F egg=@dist/project-1.0-py3.7.egg
{"node_name": "ubuntu", "status": "ok", "project": "myproject", "version": "r1", "spiders": 2}

@my8100 my8100 closed this as completed Jul 15, 2019
@my8100 my8100 added the status: invalid not a Scrapyd issue, an accidental PR or an improper approach label Jul 15, 2019
@Digenis Digenis added type: bug and removed status: invalid not a Scrapyd issue, an accidental PR or an improper approach labels Jul 15, 2019
@Digenis
Copy link
Member

Digenis commented Jul 15, 2019

It is a bug. The expected behaviour is raising "ValueError('Uknown or corrupt egg')"
activate_egg relied on find_distributions to let a StopIteration bubble up from somewhere.
Now it returns an empty tuple instead of an empty iterator.
This may be related to PEP-479 or other python3 changes.

@Digenis Digenis reopened this Jul 15, 2019
@Digenis Digenis changed the title Error when using addversion api Activating an invalid egg doesn't raise a helpful exception in py36 Jul 15, 2019
@Digenis Digenis changed the title Activating an invalid egg doesn't raise a helpful exception in py36 Activating invalid egg doesn't raise helpful exception in py36 Jul 15, 2019
@jpmckinney jpmckinney changed the title Activating invalid egg doesn't raise helpful exception in py36 Activating invalid egg doesn't raise helpful exception Jan 30, 2023
jpmckinney added a commit that referenced this issue Jul 16, 2024
…tead of "TypeError: 'tuple' object is not an iterator", #282
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants