Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: macosx timers don't fire if plt.show() hasn't been called #23061

Closed
Milestone
@greglucas

Description

@greglucas

Bug summary

There are no leaks when we plt.show() figures and fire up the GUI mainloop. However, when we are calling savefig() without ever showing we are now creating singleshot Timers in the app, but the callback never gets triggered due to the event loop not being active/listening for these timers. This is then keeping a reference from the Timer to the Figure on every close, causing a leak when calling a bunch of savefig's.

xref:#19769
But, more specifically related to Timer's generically not firing.
identified debugging:#23059

Code for reproduction

importsysimportmatplotlib.pyplotaspltimportnumpyasnpimportmatplotlib#matplotlib.use('agg')data=np.random.rand(60,60)defplot_expr(plot_name):plt.figure(figsize=(9,8))foriinrange(60):plt.plot(data[i, :])plt.savefig(plot_name)plt.close('all')if__name__=="__main__":print(f'python:{sys.version}')print(f'matplotlib:{matplotlib.__version__}')print(f'backend:{matplotlib.get_backend()}')foriinrange(50):print(f'{i}...')plot_expr(f'leak_{i}')

Actual outcome

Timer's don't fire. You can put a log inside the callback to verifyNSLog(@"Inside callback") that the Timer gets created but doesn't trigger.

Expected outcome

Timer's should fire even if we aren't interactive.

Additional information

No response

Operating system

MacOS

Matplotlib Version

main

Matplotlib Backend

macosx

Python version

No response

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp