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

calculating greens functions breaks pipes #2

Open
jboguski opened this issue Apr 1, 2020 · 3 comments
Open

calculating greens functions breaks pipes #2

jboguski opened this issue Apr 1, 2020 · 3 comments

Comments

@jboguski
Copy link

jboguski commented Apr 1, 2020

Using Windows 10, python 3.7.6, running the juypter notebook pleiades_intro.ipynb works great, but running the same code in a .py file in ipython causes the following error:

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\temp.py", line 40, in
brb.grid = RZgrid

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\pleiades\core.py", line 1751, in grid
comp.grid = grid

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\pleiades\core.py", line 944, in grid
self.compute_greens()

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\pleiades\core.py", line 885, in compute_greens
p.start()

File "C:\Users\l284987\anaconda3\lib\multiprocessing\process.py", line 112, in start
self._popen = self._Popen(self)

File "C:\Users\l284987\anaconda3\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)

File "C:\Users\l284987\anaconda3\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)

File "C:\Users\l284987\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 89, in init
reduction.dump(process_obj, to_child)

File "C:\Users\l284987\anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)

BrokenPipeError: [Errno 32] Broken pipe

I tried inserting:

for c in brb.components:
c.nprocs=1

right before:
brb.grid = RZgrid

but it failed to set the number of processors used to 1, it gave the following error:

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\temp.py", line 40, in
c.nprocs=1

File "C:\Users\l284987\Documents\Python Scripts\pleiades-develop\pleiades\core.py", line 963, in nprocs
if len(new_nprocs) != self._num_groups:

TypeError: object of type 'int' has no len()

@eepeterson
Copy link
Owner

eepeterson commented Apr 1, 2020

Oh the type error at the end is because nprocs has to be iterable and be the same length as the number of groups in the component so replace c.nprocs = 1 with something like c.nprocs = [1]*c.num_groups. That should get rid of the TypeError.

As for the broken pipe, are you running the .py file in IPython itself or are you just running python test_pipe_error.py? where test_pipe_error.py is the name of your python file

@eepeterson
Copy link
Owner

eepeterson commented Apr 2, 2020

So after a little digging I found this thread that describes that using the multiprocessing module in interactive Python especially on windows has a lot of problems associated with it. The way the multiprocessing is handled now in the code is not how I'd like it done so I may rewrite it and I'll keep this in mind when doing that, but I believe the solution to this for now is to use [Jupyter notebooks](<https://jupyter.org/) if you want an interactive environment. Or simply execute a standard .py file using the non-interactive interpreter.

@eepeterson
Copy link
Owner

eepeterson commented Apr 2, 2020

If you care to read a little about why this doesn't work, you can check out the links here, here, and here. If you try putting all the code you're trying to execute inside an if __name__ == '__main__': clause as shown in this post I believe it should work for you as a python script on windows.

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

2 participants