ipython: BUG: The current event queue and the main event queue are not the same.

Version info

OSX 10.11.6 IPython 5.1.0 ITerm2 Build 3.0.7 Python 3.5.2

This might be a long shot since it’s kind of specific, but I thought I’d report it anyway. The following function is causing the error. It errors out in IPython, but not in a regular python3 shell session.

Function

TL;DR: The following description may be irrelevant, as the error is indicated as happening at the first call to input()

It essentially just prompts for a document number, then another document (ECR) number, and check if those ECRs have that Doc in a specific field in an sqlite table (the ismember function just checks for membership in a comma-delimited string, e.g. ismember('Doc-1', 'Doc-1,Doc-2,Doc-3') = True)

def doc_checks(db_path):
    """Check if a doc has inputted associated ECRs, supposedly"""
    ecrs=''
    doc=''
    db = sqlite3.connect(db_path)
    db.create_function("ismember",2,eu.ismember)
    cur = db.cursor()
    try:
        while True:
            doc = input('Enter a doc number: ')
            if doc=='stop':
                break
            while True:
                ecrs = input('Enter associated ECRs: ')
                if ecrs =='stop':
                    break
                ecrs = [ecr.strip() for i in ecrs.split(',')]
                cur.execute(
                    "UPDATE MasterECR SET RecordList = "
                    "CASE NOT ismember(?,RecordList) THEN RecordList||','||? "
                    "ELSE RecordList END "
                    "WHERE ECRNumber IN {0}"
                    .format('('+','.join('?'*len(ecrs))+')'),
                    (doc,doc,*ecrs)
                )

        db.commit()
    finally:
        db.close()

Error

This is the error being returned by IPython

Enter a doc number: 2016-08-15 15:57:20.677 Python[9739:1314371] !!! BUG: The current event queue and the main event queue are not the same. Events will not be handled correctly. This is probably because _TSGetMainThread was called for the first time off the main thread.
---------------------------------------------------------------------------
EOFError                                  Traceback (most recent call last)
<ipython-input-6-fcb666389ca2> in <module>()
----> 1 doc_checks('CAS/MasterData/MasterData.db')

/Users/diego/Dropbox (MIT)/JPL/Working/scratch.py in doc_checks(db_path)
     15     try:
     16         while True:
---> 17             doc = input('Enter a doc number: ')
     18             if doc=='stop':
     19                 break

EOFError:

As mentioned before, it runs normally on a regular python3 session, or at least this error does not occur.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I have it all the time I use tab in ipython (not notebook): MacOS, python 3.6, zsh, conda virtualenv

Wait, it happened again! I think it’s happening when the autocomplete lags (which is very weird - it didn’t used to happen?)

lag

The pause is me hitting tab and then waiting for a while, and then typing a lot because the terminal isn’t responding. And then suddenly it responds. But perhaps these things are related and there’s something like a race condition.