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

error_callback when using apply_async in python 2.7 #91

Open
lizaclark opened this issue Mar 16, 2016 · 2 comments
Open

error_callback when using apply_async in python 2.7 #91

lizaclark opened this issue Mar 16, 2016 · 2 comments

Comments

@lizaclark
Copy link
Contributor

When I call rvic.parameters.parameters with multiple cores in Python 2.7.11, I get the following error:

INFO:parameters>> On Outlet 1 of 1
ERROR:write>> Traceback (most recent call last):
ERROR:write>> File "run_rvic.py", line 62, in
ERROR:write>> main()
ERROR:write>> File "run_rvic.py", line 56, in main
ERROR:write>> rvic.parameters.parameters(param_cfg_name, numofproc=cores)
ERROR:write>> File "/d6/eclark/miniconda2/envs/otl_env/lib/python2.7/site-packages/rvic-1.1.0-py2.7-linux-x86_64.egg/rvic/parameters.py", line 73, in parameters
ERROR:write>> error_callback=error)
ERROR:write>> TypeError
ERROR:write>> :
ERROR:write>> apply_async() got an unexpected keyword argument 'error_callback'

Apparently error_callback is not a keyword option for apply_async in python 2 (ref). In this case, it looks like nothing happens if there is an error; the callback just isn't called. I can think of 3 options for how to handle this:

  1. Put in a python version check that disables multiprocessing for python 2.
  2. Make a function that only uses error_callback if user is using python 3. Set up an error check in the stat return value of apply_async to show if the job completed or not. The problem, of course, being that you don't get the error code from gen_uh_run.
  3. Add something like this traceback function to gen_uh_run.
@bartnijssen
Copy link
Member

My vote is for 1) since there is no good reason to keep everything compatible with python 2.

@jhamman
Copy link
Member

jhamman commented Mar 17, 2016

I think we can just leave out the error_callback argument in python 2.7.

Some psudo code:

def _make_async_kwargs():
    kwargs = dict(callback=store_result)
    if py3:
        kwargs['error_callback'] = error
    return kwargs
        kwargs = _make_async_kwargs()
        for i, (key, outlet) in enumerate(iteritems(outlets)):
            log.info('On Outlet #%s of %s', i + 1, len(outlets))
            stat = pool.apply_async(gen_uh_run,
                                    (uh_box, fdr_data, fdr_vatts,
                                     dom_data, outlet, config_dict,
                                     directories),
                                    **kwargs)

@lizaclark - do you know if stat.get() will raise an error in Python 2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants