Open norfordb opened 6 years ago
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.
@norfordb thanks! OK, I think I know what the problem is. The figure
module only works inside a GMT modern mode session, which is initiated by a gmt begin
command. We're running this at import time. When you pass the function to a new process, the import gmt
didn't happen in that process so gmt begin
was never called there.
I'll try to think of a way around this. For now, we'll your code as a test case so we know how it works.
Again, thank you for reporting this! :1st_place_medal:
Thanks a lot for reporting this problem - I was really scratching my head why plotting in parallel didn't work!
For the record, here is how I work around this error for now: One can manually reload pygmt
at the top of the function that is run in parallel (gmt_fun
in the example above), like:
from importlib import reload
def gmt_fun(n):
import pygmt
reload(pygmt)
...
Thanks a lot for reporting this problem - I was really scratching my head why plotting in parallel didn't work!
For the record, here is how I work around this error for now: One can manually reload
pygmt
at the top of the function that is run in parallel (gmt_fun
in the example above), like:from importlib import reload def gmt_fun(n): import pygmt reload(pygmt) ...
Thanks for your solution.
It works on my linux(centos) machine. But, does not works on my windows machine. In linux, the session path use PID of child process. But in windows, the session path use PID of parent process.
Feedback or description of feature requested
When attempting to call a script using gmt-python by way of the python multiprocessing library (multiprocessing.pool), an error is returned, as shown below.
Are you willing to help implement and maintain this feature? No
Full code that generated the error
The code does work with the following change:
Full error message
System information
conda list
below: