question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

peewee.InterfaceError: (0, '') | pymysql.err.InterfaceError: (0, '')

See original GitHub issue

I am encountering this exception (using high-level api) then my asyncio based daemon is idle (about 15 minutes or so), after that time, this exception occurs, I have tried to close and reopen connection, and was surprised that Manager (high-level api) did not track its state (close/reopen is done using its methods).

after reopening a connection I’ve got stuck with a bunch of coroutines waiting for resolution which obviously will never come. =(

  1. can it be a bug in pymysql/peewee
  2. propose add connection status tracking to high-level Manager

any thoughts on how to fix that?

Traceback (most recent call last):
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3748, in execute_sql
warehouse_1        |     cursor.execute(sql, params or ())
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 166, in execute
warehouse_1        |     result = self._query(query)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 322, in _query
warehouse_1        |     conn.query(q)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/connections.py", line 851, in query
warehouse_1        |     self._execute_command(COMMAND.COM_QUERY, sql)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/connections.py", line 1067, in _execute_command
warehouse_1        |     raise err.InterfaceError("(0, '')")
warehouse_1        | pymysql.err.InterfaceError: (0, '')
warehouse_1        | 
warehouse_1        | During handling of the above exception, another exception occurred:
warehouse_1        | 
warehouse_1        | Traceback (most recent call last):
warehouse_1        |   File "/opt/app/storage/sql.py", line 357, in _wrapper_catch_db_excetions
warehouse_1        |     return await fn(*args, **kwargs)
warehouse_1        |   File "/opt/app/storage/sql.py", line 415, in update
warehouse_1        |     await self._manager.create(Item2Source, item_id=existing.id, source_id=source.id)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee_async.py", line 183, in create
warehouse_1        |     pk = inst._get_pk_value()
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 5017, in _get_pk_value
warehouse_1        |     return getattr(self, self._meta.primary_key.name)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 1553, in __get__
warehouse_1        |     for field_name in self.field_names])
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 1553, in <listcomp>
warehouse_1        |     for field_name in self.field_names])
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 1363, in __get__
warehouse_1        |     return self.get_object_or_id(instance)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 1354, in get_object_or_id
warehouse_1        |     obj = self.rel_model.get(self.field.to_field == rel_id)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 4900, in get
warehouse_1        |     return sq.get()
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3161, in get
warehouse_1        |     return next(clone.execute())
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3213, in execute
warehouse_1        |     self._qr = ResultWrapper(model_class, self._execute(), query_meta)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 2892, in _execute
warehouse_1        |     return self.database.execute_sql(sql, params, self.require_commit)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee_async.py", line 1024, in execute_sql
warehouse_1        |     return super().execute_sql(*args, **kwargs)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3755, in execute_sql
warehouse_1        |     self.commit()
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3578, in __exit__
warehouse_1        |     reraise(new_type, new_type(*exc_args), traceback)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 135, in reraise
warehouse_1        |     raise value.with_traceback(tb)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/peewee.py", line 3748, in execute_sql
warehouse_1        |     cursor.execute(sql, params or ())
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 166, in execute
warehouse_1        |     result = self._query(query)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 322, in _query
warehouse_1        |     conn.query(q)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/connections.py", line 851, in query
warehouse_1        |     self._execute_command(COMMAND.COM_QUERY, sql)
warehouse_1        |   File "/usr/local/lib/python3.5/site-packages/pymysql/connections.py", line 1067, in _execute_command
warehouse_1        |     raise err.InterfaceError("(0, '')")
warehouse_1        | peewee.InterfaceError: (0, '')

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Xandaroscommented, Mar 14, 2018

I am also encountering this. I use flask with socketio, which, as far as I know, uses coroutines or something similar. Maybe it is connected to async, after all?

I am not using anything fancy from peewee - just the high level API. And indeed, it happens after long idle time.

Edit: Looks like I got the wrong repo, I’m actually using normal peewee. This is still an issue for me, though. Maybe this will help you narrow it down.

1reaction
dikderoycommented, Mar 28, 2017

my test is designed to show what bug appears in simple, real-world scenario, “crazy-monkey method” to speed up tests - is just a way of getting work done faster =)

Here is another thing which can help to track the cause - in all variations of code and execution graphs - it always fail while working with Item2Source - which is not like other 2 models - it is a many2many table relation (composed of 2 foreignkey fields and having them as composite pk)

I am not familiar with peewee internals but it looks connected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pymysql.err.InterfaceError: (0, '') · Issue #1546 · coleifer/peewee
I am encountering this exception (using peewee-async high-level api) then my asyncio based daemon is idle (about 15 minutes or so), after that...
Read more >
Finding source of PyMySQL error - err.InterfaceError("(0
The bot is built using Discord.py and uses Peewee as an ORM, using PyMySQL as the database driver. The server the client is...
Read more >
peewee.OperationalError: MySQL server has gone away - done
I'm seeing the following error on a pretty regular basis. ... InterfaceError: (0, '') During handling of the above exception, another exception occurred: ......
Read more >
Developers - peewee.InterfaceError: (0 - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >
Finding source of PyMySQL error - err.InterfaceError("(0
The bot is built using Discord.py and uses Peewee as an ORM, using PyMySQL as the database driver. The server the client is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found