Issue: (2006, "MySQL server has gone away (error(32, 'Broken pipe'))")
Author: emamirazavi
State: closed
Created: 2015-02-26 16:24:44

When i want to save my model, my connection broke! and raises an exception with title of this issue, but mysql logfile reads:
INSERT INTO `inboundmsg` (`tojid`, `fromjid`, `type`, `datetime`, `content`, `url`, `size`, `local`, `status`) VALUES ('989393310102', '989102260264', 'image', '2015-02-26 19:43:11.789153', '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABKAGQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDz22+K15Y2i21jahURQqtJMztgflUA+JN9eP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gvL6eO5dd3eipfGFnLpuv3Vo67GiO3HXPvnvmikoo1uzpzMAOtC3QUfe+nNUiflqB+n417s1qeSzdh1L5gsjY9DV631QRzBS3B6HNcbcE7hyauEnbEc84qBI7eW/wAJuQkkc1K2pG7sJofMIZ0IFc/ETheT0qO3JAbBI+Y0Ad58NNYa+07ZcyJLLa5dYpVGN6nk/XaGwfevR7y6+1eHo5dMQ3OlXStlVdU8oDoV4wy5BGDk9OK8N+FZJ8QopJKtdMCOxBJyK9S0N3t/EGtWtuzRWsdzHshQ7UXLc4UcDNcGIjaR24d3ieKeOJktfE2r6NpsAncvFLBDbIWbc6HcoQcg5AyO2a3PDng68062ubDxEhtH1OMSBd4dolOQdw6Bgece1c54cd2/aG1CQsxkF1L8xPP3fWvSvFBLeONHjYlo206Msp5BJZskislUekPIdSklF1PM8dg0PU/Cni2eKwjn1bTXVhJNZQl1kjboCQDtNfUPhay/tTwzbxGW4t7t7dXeKVd8kQ7DcBkH2JzW34LtoIIJI4IYo41AwqIAB+AqeaWRby5CyOAJIAAGPGSc0laWo/I861H4LWuqXH2xrqRmkUEmaPa34gjIor0++J87r2/xoqfYRL9vI//Z', 'https://----/d/xOX7wcwGDoX13Mmk-7xHZlTvRhcABRAAB0IQjQ/An-vJIOekxRv77ykjdGy6LOTtwk_j-3GcAq1VBeQ-pNt.jpg', 57180, '5dce934c-bdd2-11e4-b641-6c8814f85df8.jpg', '3')

and has not any error!!!
any idea about peewee? peewee is being boring for me...

I use playhouse to make pool and this is my pool instance:
my_db = PooledMySQLDatabase(dbconfig['database'], host=dbconfig['host'], 
                            port=dbconfig['port'], user=dbconfig['user'], 
                            passwd=dbconfig['password'], threadlocals=True, max_connections=None,
                            charset='utf8mb4')
also i use flask for web interface


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


For an alternate fix, see also 017e4e4952f0b429dd21f0e90465a0f644cf6015


For a new alternate fix:
```python
from playhouse.shortcuts import ReconnectMixin


class MyRetryDB(ReconnectMixin, MySQLDatabase):
    pass
```