-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
AttributeError: 'module' object has no attribute '__main__' #133
Comments
Can you post a reduced sample of your code, and the traceback, as well as the versions of python and modules you are using? Neither this ticket nor the link to stackoverflow gives enough information to reproduce an error… so I can't see what you are seeing, and thus can't ascertain if or what needs to be addressed. |
This unfortunately is yet again another bug that occurs with very low frequency in a code base that interacts with the iPython cluster and dill at a high level of abstraction so it is difficult for me to give you a reproducer at present. I will see what I can do. |
|
Sorry this is so gross. This is the version info from
|
Ok, fine, I can deal with that. So how about some code? |
From watching this bug arise, I think I am seeing this in relation to code like that seen in this issue ( #135 ). In particular, if I use the workaround proposed there, I run into an issue with code looking like this. However, this doesn't quite reproduce it.
|
Can you also post the Traceback you are seeing? |
I can confirm the error. I could work around it by importing import ipyparallel
engines = ipyparallel.Client()
balancer = engines.load_balanced_view() %%px --local
import pickle ipyparallel.canning.use_dill()
engines[:].apply_sync(ipyparallel.canning.use_dill); |
@tcwalther: Thanks. I'll see if I can reproduce the error. Any code that reliably produces the error would be very helpful. If your workaround does indeed work, it might be require a patch for @jakirkham or @tcwalther, do you know if this is an existing issue/ticket for |
I don't believe there is an existing issue on |
I've punted this issue to |
We just had the same issue. We're using celery rather than [2016-03-03 23:43:23,055: ERROR/Worker-99] Pool process <Worker(Worker-99, started daemon)> error: AttributeError("'module' object
has no attribute '__main__'",)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 295, in run
sys.exit(self.workloop(pid=pid))
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 356, in workloop
req = wait_for_job()
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 447, in receive
ready, req = _receive(1.0)
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 419, in _recv
return True, loads(get_payload())
File "/usr/local/lib/python2.7/dist-packages/billiard/common.py", line 77, in pickle_loads
return load(BytesIO(s))
AttributeError: 'module' object has no attribute '__main__'
[2016-03-03 23:43:23,059: ERROR/MainProcess] Process 'Worker-99' pid:10938 exited with 'exitcode 1' If we use Is there any other info that would be helpful? |
@MaximilianR: Yes, this is helpful. Does it always occur? or is it infrequent, as when seen in I haven't been able to reproduce the error in |
@jakirkham: I just noticed you said "seeing this error on the new release, which I hadn't seen on the last release"… you are referring to |
It was in the version listing above. Though admittedly that is not easy on the eyes. I have added it to the issue summary. The version was |
@jakirkham: aha… I didn't see that. So, in version |
No worries. I think it was true of the previous version ( |
This isn't conclusive, in trying to make a reproducible example I found this: I think it may be when pickle is used to unpickle the function. (NB to those that don't know: you shouldn't use unserialize the strings I post here, you should generate your own, as it's a security risk for you) import dill
In [2]:
def n(a):
return a*2
In [3]:
dill.dumps(n)
Out[3]:
'\x80\x02cdill.dill\n_create_function\nq\x00(cdill.dill\n_unmarshal\nq\x01Uwc\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\x08\x00\x00\x00|\x00\x00d\x01\x00\x14S(\x02\x00\x00\x00Ni\x02\x00\x00\x00(\x00\x00\x00\x00(\x01\x00\x00\x00t\x01\x00\x00\x00a(\x00\x00\x00\x00(\x00\x00\x00\x00s\x1e\x00\x00\x00<ipython-input-2-ac332b335aa3>t\x01\x00\x00\x00n\x01\x00\x00\x00s\x02\x00\x00\x00\x00\x01q\x02\x85q\x03Rq\x04c__builtin__\n__main__\nU\x01nq\x05NN}q\x06tq\x07Rq\x08.' This works fine: #restart process
In [1]:
import dill
In [2]:
dill.loads('\x80\x02cdill.dill\n_create_function\nq\x00(cdill.dill\n_unmarshal\nq\x01Uwc\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\x08\x00\x00\x00|\x00\x00d\x01\x00\x14S(\x02\x00\x00\x00Ni\x02\x00\x00\x00(\x00\x00\x00\x00(\x01\x00\x00\x00t\x01\x00\x00\x00a(\x00\x00\x00\x00(\x00\x00\x00\x00s\x1e\x00\x00\x00<ipython-input-2-ac332b335aa3>t\x01\x00\x00\x00n\x01\x00\x00\x00s\x02\x00\x00\x00\x00\x01q\x02\x85q\x03Rq\x04c__builtin__\n__main__\nU\x01nq\x05NN}q\x06tq\x07Rq\x08.')
Out[2]:
<function __main__.n> But this fails, as expected: >>> import cPickle
>>> cPickle.loads('\x80\x02cdill.dill\n_create_function\nq\x00(cdill.dill\n_unmarshal\nq\x01Uwc\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\x08\x00\x00\x00|\x00\x00d\x01\x00\x14S(\x02\x00\x00\x00Ni\x02\x00\x00\x00(\x00\x00\x00\x00(\x01\x00\x00\x00t\x01\x00\x00\x00a(\x00\x00\x00\x00(\x00\x00\x00\x00s\x1e\x00\x00\x00<ipython-input-2-ac332b335aa3>t\x01\x00\x00\x00n\x01\x00\x00\x00s\x02\x00\x00\x00\x00\x01q\x02\x85q\x03Rq\x04c__builtin__\n__main__\nU\x01nq\x05NN}q\x06tq\x07Rq\x08.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__main__' |
@jakirkham: So when you say, hadn't seen on the last release, did you mean the previous release of |
@MaximilianR: Interesting… hmm. |
@MaximilianR: your example even fails if you use |
|
Yup! |
I'm trying to figure out how to best resolve this ticket… I am still of the mind that this is not directly an issue with One possible resolution is that I: (1) close this ticket as it doesn't seem to be a So… my inclination is to close this ticket saying "don't use Does that sound reasonable? Any other suggestions? |
As a pedestrian with the same issue since one week ago (it wasn't happening before), should I change the default value of 'recurse' to True in the python2.7/site-packages/dill/settings.py file ?? Thanks! |
@diego-mazon: To me it smells like |
Thanks, @mmckerns . Just in case this helps: Now it's working fine for me with no need of setting |
Seeing this error on the new release (
dill 0.2.4
), which I hadn't seen on the last release. Using Jupyter/iPython cluster. Related questions ( http://stackoverflow.com/questions/27597778/why-do-i-get-a-module-has-no-attribute-main-in-ipython-parallel-gather-state )The text was updated successfully, but these errors were encountered: