-
Notifications
You must be signed in to change notification settings - Fork 45
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
Exception when leaving the app in debug mode #37
Comments
something weird is happening according to that traceback, I'll need more context. The default logger handler just sends the data to stderr, but it looks like you have a logger set to log to a file, and then somehow that's triggering an error inside the logging module ("NameError: name 'open' is not defined). It's... super bizarre. So things to isolate:
|
Just shooting into the dark here, is it possible that the logger is only triggered that far in the shutdown phase that some builtins are not available anymore already? I don’t know whether the logging module opens the file for each message or opens it once for all. In the latter case, the theory should be dismissable by emitting a log at the start of the application. |
I'm using latest python (3.4) on archlinux. If I disable logging to a file, here are the logs that seems to create the crash :
|
That... doesn't look like a crash though, so if you don't log to a file it (see "process finished with exit code 0") On Fri, Jul 24, 2015 at 9:04 AM, Insoleet [email protected] wrote:
|
Yes, exactly.
never logs if I enable logging to a file. Instead, I get a crash. It seems that these logs are the cause of the crash when I enable logging to a file. |
@Insoleet Can you try logging an error during application start up? Does this make the crash go away? |
Sure I can try it ! Where should I put it in the following lines ? if __name__ == '__main__':
# activate ctrl-c interrupt
signal.signal(signal.SIGINT, signal.SIG_DFL)
cutecoin = QApplication(sys.argv)
loop = QEventLoop(cutecoin)
asyncio.set_event_loop(loop)
with loop:
app = Application.startup(sys.argv, cutecoin, loop)
window = MainWindow(app)
window.startup()
loop.run_forever()
sys.exit() And to be clear on one point that I think I was not clear enough :
|
@Insoleet Before the |
Ok the behaviour is really weird with logging in these lines. If I add
|
Could this be linked to this bug : #34 ? |
Are you talking about the "Task was destroyed but it is pending!" errors? those could be related, but the crash is a bug in the python logging module, or expected behaviour depending on how you look at it. Looks like you can work around the logging by sending data through the logger to make sure it gets initialized, then if it encounters any error messages during shutdown, it can handle them. Also #34 is just generally out of my league in terms of debugging it, it's kind of a heisenbug though since it involves the garbage collector. |
The problem is that if I initialize the logger before the with loop by sending data to it... I don't have any application log going out. Only the ones emitted by quamash after the loop ! |
That sounds like a bad logging configuration, are you just using |
Here is my code to initialize logging : if options.debug:
logging.basicConfig(format='%(levelname)s:%(module)s:%(message)s',
level=logging.DEBUG)
elif options.verbose:
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.INFO)
else:
logging.getLogger().propagate = False |
And this is all running with |
Yes ! def parse_arguments(argv):
parser = OptionParser()
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
help="Print INFO messages to stdout")
parser.add_option("-d", "--debug",
action="store_true", dest="debug", default=False,
help="Print DEBUG messages to stdout")
(options, args) = parser.parse_args(argv) |
I guess you need to start stepping through with a debugger to figure out what's eating the logging messages when logging is initialized vs not. I wish I had more info to narrow down some the search space some, but I do not. |
To sum it up :
I'll try to get more info. To be continued... |
The logging is not printed because I didn't run After initializing logging and the FileHandler before Here is something interesting. If I add a breakpoint in the EDIT : In fact, it does not crash but the processes never close. The last logs :
|
That lends more credence to the relation to #34 theory, but I need help from someone who really understands python's garbage collector to fix that one. |
Do you know anyone which could be of some help ? Maybe you should ask on the python mailing list ? |
I went ahead and asked here: https://groups.google.com/d/topic/python-tulip/7S4RX_XVOr4/discussion |
This one is fixed. |
Hello,
When exiting our app in debug mode quamash crashes with the following exception :
The text was updated successfully, but these errors were encountered: