-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Process hang while executing logging.warning under specific circumstances #1166
Comments
That's very odd, I don't know why it would hang. If you interrupt it while it's hanging, do you get any traceback? There was a change to the logging setup in the kernel recently - #127. Can you try installing ipykernel from master and see if that makes a difference? |
There is no backtrace or any other information when I interrupt the kernel. I installed the current ipykernel master (commit: ffadc63 ). There is no difference in the behavior compared to the one currently available with pip. Do you have any ideas what I can do to further debug this issue? |
Not really, I'm afraid. Double check that it is definitely the log call hanging and not anything else nearby in the code. Dig into the logging module to try to work out exactly what is hanging. |
@takluyver do you think this is the same issue, and does it help identify what's going wrong? Thanks! |
On Windows I'd guess that the issue is trying to write to a nonexistant stderr; once some buffer fills up, the next write call will block. We've seen this before on Windows. This issue was reported on a Mac, so I doubt it's the same, but the cause may be similar. |
I have the same issue when trying to import module rdflib at https://github.com/RDFLib/rdflib. When importing rdflib from python, it logs this line: INFO:rdflib:RDFLib Version: 4.2.1. And importing from jupyter, the kernel just hang there. UPDATE: jupyter==1.0.0 Currently, I run this code (disable logging) before importing module to work around this bug:
|
I ran into the same problem with one of my own packages last week. Ultimately, this appears to be caused by Python's import lock causing a deadlock when ipkernel.iostream.OutStream.flush is called (by logging.warning or otherwise) during an import. Because of changes to the import logic, the problem may disappear when running in Python >= 3.3 (not tested). OutStream.flush schedules OutStream._flush in a separate thread (pub_thread), and, via jupyter_client.session.Session.send, Session.msg, Session.msg_header, Session.msg_id and uuid.uuid4, triggers an import in pub_thread which blocks if an import is running in the main thread. At the same time, OutStream.flush waits for pub_thread to return from _flush, resulting in a deadlock. Minimal example that triggers the behavior:
Execution traces of the main thread and pub_thread. |
That deadlock should be fixed in ipykernel 4.5.2, so upgrading ipykernel should solve it. |
Unfortunately, I see the same behavior with ipykernel 4.5.2 (other versions are jupyter_client 4.4.0, jupyter_core 4.2.1, notebook 4.3.1). |
I was able to reproduce it with these simple steps:
Please note, that it happens only on import, i.e. it doesn't happen when one runs a python file as a script. The environment:
OS X Sierra 10.12.3 (16D32) |
I haven't verified if this is still an issue, but moving it to the |
I identified a kernel hang when calling the python logging facility under certain circumstances. The hang is specific for usage of function in jupyter, i.e. it does not happen in a ipython command shell.
The hang happens when I import a specific module form this repository: https://github.com/secdev/scapy/ (the issue can be reproduced with the version from pip as well).
The hang happens in line 234 when this method is called
warning() is a wrapper that calls
where x is the message. I am not able to reproduce this issue in a smaller test case, i.e. I cannot find other situations where a call to logging.warning() hangs the kernel.
The reason why I open this issue with jupyter is that the jupyter notebook is the only environment where this results in a hang. The code works without issues in the standard python2.7 interpreter, and in the ipython command shell
I experience the issue on Mac OS X with the following python, and package versions
ipython and jupyter versions are:
Is there any additional information that I can provide to further debug this problem?
The text was updated successfully, but these errors were encountered: