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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PyCall.__init__ when no __main__ present #819

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

marius311
Copy link
Contributor

@marius311 marius311 commented Sep 15, 2020

In some environments, __main__ isn't a module, eg on an ipyparallel worker __main__ is a IPython.core.interactiveshell.DummyMod, causing PyCall to error on loading because that pyeval_ is trying to use __main__ by default. Or worse, if you've compiled a custom sysimage with PyCall (eg for pyjulia), then an error during __init__ means a segfault. This fixes that.

Actually, with this PR, I can now run an ipyparallel cluster of Python workers calling Julia via pyjulia w/ custom sysimage 馃帀

$ ipcluster start -n 1 & # start workers
$ ipython
In [1]: import ipyparallel as ipp 
   ...: c = ipp.Client() 
   ...: c.ids                                                                                                                       
Out[1]: [0]

In [2]: %autopx                                                                                                                     
%autopx enabled

In [3]: from julia.api import LibJulia 
   ...: api = LibJulia.load()
   ...: api.sysimage = "sys.so"
   ...: api.init_julia()
   ...: import julia.Main                                                                                                  

In [4]: julia.Main.eval("1+2")                                                                                                      
Out[0:2]: 3

Seems a decent bit of people on the pyjulia Issues have been trying do similar stuff (also with multiprocessing and/or Dask), maybe this will be a helpful solution to point out there assuming this PR makes sense to you guys.

@stevengj stevengj merged commit 14f77cc into JuliaPy:master Sep 15, 2020
@stevengj
Copy link
Member

Looks good, thanks.

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

Successfully merging this pull request may close these issues.

None yet

2 participants