cosmic-ray: HTTP Distributor Tutorial is Broken on Windows
I’m on Python 3.9.6 and following the HTTP Distributor tutorial produces the following error:
Traceback (most recent call last):
File "c:\users\admin\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\admin\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Scripts\cosmic-ray.exe\__main__.py", line 7, in <module>
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\cli.py", line 288, in main
return cli(argv)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\cli.py", line 115, in handle_exec
cosmic_ray.commands.execute(work_db, cfg)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\progress.py", line 98, in wrapper
return func(*args, **kwargs)
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\commands\execute.py", line 46, in execute
distributor(
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\distribution\http.py", line 45, in __call__
asyncio.get_event_loop().run_until_complete(self._process(*args, **kwargs))
File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\cosmic_ray\distribution\http.py", line 87, in _process
done, pending = await asyncio.wait(fetchers.keys(), return_when=asyncio.ALL_COMPLETED)
File "c:\users\admin\appdata\local\programs\python\python39\lib\asyncio\tasks.py", line 392, in wait
raise ValueError('Set of coroutines/Futures is empty.')
ValueError: Set of coroutines/Futures is empty.
Where can I find the latest Python version that Cosmic Ray supports?
Also, I am not sure if the problem is with the tutorial, with Cosmic Ray itself, or an incompatibility with the version of Python on my system.
Any advice?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (14 by maintainers)
Thanks for doing that. It really helps me keep track of what’s going on.
I’m actually ready to close this issue. I’m nearly certain that #516 addresses your initial problems. It’s not an issue on windows, just an issue with my logic in the HTTP distributor. So I’ll close this issue and sort things out over there.
Could you bundle these documentation issues up into another issue? That’ll make it easier for me to keep track of them. Or, if you’re feeling energetic, you could update the docs yourself; I’m always happy to get these kinds of contributions because they almost always deal with my particular blind spots.
Not right now. Something like this would presumably require syntactic analysis of the code, so it wouldn’t be trivial (though I don’t think it would be terribly complicated either). There may even be an existing library we could leverage that helps us process the pragmas.
If this is something you’d like, it would be helpful to create another issue for it.
CR tries hard to avoid this possibility, but it might still be possible. Tests are run in a subprocess, so even if they die horribly, the CR worker process should be able to undo the mutations. Generally speaking, though, I’d recommend committing everything prior to testing; this will be important, for example, if you’re using the
cr-http-workers
tool that clones your repo as part of its operations.This isn’t always strictly necessary. For example, changing your distributor won’t require a re-initialization. Changing your test-command or excluded-modules generally would necessitate a re-init since this would effect which tests are run (thus potentially invalidating existing results).
Not currently, though that should be straightforward to implement if you’re so inclined.
On a *nix system you could do something like:
It looks like this feature doesn’t work right now. I’ve create #517 as a reminder to reimplement this as a filter.
Yes, that looks correct. Regular expressions are an option, not a requirement. In your case of excluding a single operator, what you’ve done is fine.
Our pragma filter only works on lines of code, not code blocks. It’s quite a crude filter, really, but sufficient for many purposes.
init
completely rewrites the session file. You don’t need to delete it.CR is designed to be robust against interrupts and crashes. To a large degree, we rely on sqlite to handle that. When you run
exec
, it looks for all of the WorkItems with no results, and these tell CR what works needs to be done. Furthermore, we only add those results after a mutation/test is complete. So if CR dies for some reason, any running tests simply die, no results are written to the session, and processing picks back up with those incomplete WorkItems next time.Ok, then there’s something more mysterious going on. I’ll have to try it out on windows.
We may have to add some sort of check that
fetchers.keys()
is not empty and, if it is, add a small sleep or something. This feels kludgy, but maybe it’s necessary for some valid reason I’m not aware of.@abingham Also, small typo in the docs:
Note that your worker must be running in the same directory as you would normally run the tests from.
I’ve updated the docs to add a note that effect.
@abingham I see. I’ve never done this before so I wouldn’t know where this standard would be documented (I assume the Python docs).
I’ll let you know the results as soon as I can. 🙂
I’m happy to help support you as much as I can, though my time is a bit limited right now. CR does work well when all of the stars align; as you’re finding, though, I struggle to keep the documentation up to date, and I don’t do any testing on Windows.
Actually, I think I see what’s going on. The call to
asyncio.wait
mentioned near the end of the stack trace is to blame. Its documentation clearly states that the first argumentfs
must not be empty, and indeed theValueError
here is complaining that it is. So insrc/cosmic_ray/distribution/http.py
around line 75 we seem to have a bit of a race condition whereurls
has no elements butfetchers.keys()
is somehow empty as well.I think the error is on lines 68-69 where we remove a task from
fetchers
before appending a URL tourls
, creating a window where bothurls
andfetchers
are empty. I thoughtasyncio
would prevent this, but perhaps not.@FloatingSunfish If you’re feeling adventurous, could you swap lines 68 and 69 in
src/cosmic_ray/distribution/http.py
, install CR from source, and try again?