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 peewee-async 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).

Traceback (most recent call last):
  File "/home/ubuntu/dati-server/match/manager.py", line 56, in clean_up_user
    await exam_end_all_handler(current_match_id, user_id)
  File "/home/ubuntu/dati-server/match/manager.py", line 407, in exam_end_all_handler
    match_result = await MatchUserRecord.set_user_score_and_winner(match_id)
  File "/home/ubuntu/dati-server/models/record.py", line 260, in set_user_score_and_winner
    score1 = await user_record1.get_match_score()
  File "/home/ubuntu/dati-server/models/record.py", line 108, in get_match_score
    answer_records = await objects.execute(UserAnswerRecord.filter(match_id=self.match.id, user_id=self.user_id))
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 1386, in __get__
    return self.get_object_or_id(instance)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 1377, in get_object_or_id
    obj = self.rel_model.get(self.field.to_field == rel_id)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 4988, in get
    return sq.get()
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 3220, in get
    return next(clone.execute())
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 3274, in execute
    self._qr = ResultWrapper(model_class, self._execute(), query_meta)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 2939, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee_async.py", line 1041, in execute_sql
    return super().execute_sql(*args, **kwargs)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 3837, in execute_sql
    self.commit()
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 3656, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/peewee.py", line 3830, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/pymysql/cursors.py", line 165, in execute
    result = self._query(query)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/pymysql/connections.py", line 859, in query
    self._execute_command(COMMAND.COM_QUERY, sql)
  File "/home/ubuntu/dati-server/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in _execute_command
    raise err.InterfaceError("(0, '')")
peewee.InterfaceError: (0, '')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
amirouchecommented, Dec 5, 2018

I think we found the issue. Looking up earlier log, we noticed mysqld server closed the only connection we had and we did not reconnect after.

ref: http://docs.peewee-orm.com/en/latest/peewee/database.html#error-2006-mysql-server-has-gone-away ref: http://docs.peewee-orm.com/en/latest/peewee/database.html#flask

Ty!

2reactions
coleifercommented, Jun 20, 2021

I’d suggest carefully debugging this because it almost certainly indicates connection mis-management somewhere in the call-stack. This can be especially true with asyncio, e.g. https://github.com/coleifer/peewee/issues/1546#issuecomment-832784804

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Database — peewee 3.15.4 documentation
As another example, the pymysql driver accepts a charset parameter which is not a standard Peewee ... 'synchronous': 0}) # Let the OS...
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