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

Let Figure.show(method='external') work well in Python scripts #1062

Merged
merged 2 commits into from
Apr 6, 2021

Conversation

seisman
Copy link
Member

@seisman seisman commented Mar 15, 2021

Description of proposed changes

See #1061 for context.

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

Comment on lines +224 to +226
# suspend the execution for 0.5 s to avoid the images being deleted
# when a Python script exits
time.sleep(0.5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using time.sleep, could we change the subprocess.run to be blocking? I.e. ensure that the subprocess run is completed before continuing to exit the function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a few ways but still can't make it blocking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think time.sleep is better than using subprocess.Popen(...).wait()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subprocess.Popen(...).wait()

Unfortunately, changing subprocess.call to subprocess.Popen(...).wait() doesn't work at all.

@weiji14 weiji14 added the bug Something isn't working label Mar 18, 2021
@seisman seisman marked this pull request as ready for review March 25, 2021 19:11
Copy link
Member

@maxrjones maxrjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of a better way for fixing this issue and this PR is necessary for the fig.show() improvements in #529 to work/be tested properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants