开发者

How can I selectively suppress certain error messages that follow a certain pattern?

I have a Python program running a thread that consistently outputs the following:

(my_program.py:12313): GLib-GIO-CRITICAL **: g_output_stream_write: assertion `buffer != NULL' failed

This prints continuously, with no obvious detrimental effect on my program. For debugging purposes, I would like to suppress this particular line without suppressing other error messages. In other words, running:

my_computer:~$ python my_program.py 2>/dev/null

cert开发者_运维百科ainly works, but it also suppresses other useful error messages.

Ideally, of course, I would address the root cause and try to eliminate this error message, but in the meantime, is there a way to selectively not display this error message?


This works:

 python my_program.py 2>&1| grep -v "GLib-GIO-CRITICAL"


That looks like a warning from GTK, are you using it? I don't think you can suppress them from Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜