Deadlock when importing a module that creates an IPython client #130

Closed
niraj-dudani opened this Issue Jun 24, 2010 · 1 comment

Projects

None yet

2 participants

@niraj-dudani

System details:
Dell Inspiron 1545 - Intel Core 2 Duo
Ubuntu 9.10 32 bit
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1](From Ubuntu repos)
OpenMPI 1.4.2 (Installed from source)
ZopeInterface 3.5.3 (Installed from source)
Twisted 10.0.0 (Installed from source)
Foolscap 0.5.0 (Installed from source)
pyOpenSSL 0.9 (From Ubuntu repos)
nose 0.11.3
IPython 0.10 (Installed from source tarball, not git repo)

(Also reproduced on a CentOS 5.2 system, with pretty much the same software configuration.)

I wrote a python module, which creates a TaskClient inside it. (The purpose was to use IPython's 'map' if available, and revert to serial 'map' if not.)

However, when I try to import this module, Python hangs at the following line:
ipc = client.TaskClient()

I can't see an "upload files" option here, so I'm including simplified scripts below. Also included below is a backtrace from pdb, showing where Python hangs. (When it hangs, it is more like a deadlock, since Python continues to perform some sort of polling).

File: ipc.py

"""
This script gets a client from IPython. It works fine if it is run by itself:
$ python ipc.py

However, if it is imported as a module (interactively, or in a script), it hangs:
>>> import ipc

It is assumed that some ipengines are running. It does not matter if the
client requested is a TaskClient or a MultiEngineClient.
"""

from IPython.kernel import client

print "Getting Client..."

ipc = client.TaskClient()

print "Got Client."

File: import_ipc.py

import ipc

Backtrace

To trace the problem, use the script 'import_ipc.py', which only does 'import ipc'.
Running this under pdb, the problem appears to be somewhere under:
IPython/kernel/twistedutil.py(72)blockingCallFromThread()

/usr/lib/python2.6/bdb.py(368)run()

-> exec cmd in globals, locals

(1)()

/home/niraj/test-ip/import_ipc.py(1)()

-> import ipc

/home/niraj/test-ip/ipc.py(15)()

-> ipc = client.TaskClient()

/home/niraj/usr/python-packages/ipython-0.10.install/lib/python/IPython/kernel/client.py(84)get_task_client()

-> furl_or_file)

/home/niraj/usr/python-packages/ipython-0.10.install/lib/python/IPython/kernel/twistedutil.py(72)blockingCallFromThread()

-> return twisted.internet.threads.blockingCallFromThread(reactor, f, _a, *_kw)

@takluyver
Member

We're moving away from twisted, so I'm closing this as it's unlikely to get attention.

@takluyver takluyver closed this Mar 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment