简体   繁体   中英

How do I clear stale entries in ipython's Notebook list?

When I run ipython notebook list from the command line, I am supposed to get a list of currently running notebook servers; but somehow some entries remain after I shut down a server. Having failed to find a session list file in ~/.ipython , I dug around in the source ( sessionmanager.py ) and found that sessions get looked up in an sqlite database:

def list_sessions(self):
    """Returns a list of dictionaries containing all the information from
    the session database"""
    c = self.cursor.execute("SELECT * FROM session")
    return list(c.fetchall())

Great, let's find the database and zap it. But the database appears to get initialized like this:

self._connection = sqlite3.connect(':memory:')

That's right, it's an in-memory database that should disappear when the process shuts down. But I've shut down every single python or notebook process I had running, and yet the zombie sessions still appear. Does anyone here understand the system well enough to explain how they stick around, and/or how to get rid of them? (I'm on OS X, if that matters).

If you want to remove them from the list, on ubuntu it is under: /home/username/.ipython/profile_default/security

You will see files like nbserver-13578.json which are created each time you launch a new notebook , if you delete them you should see an empty list when you check again using:

ipython notebook list

  Currently running servers:
  :~$ 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM