K
K
kazmiruk2013-06-18 07:43:33
MySQL
kazmiruk, 2013-06-18 07:43:33

Why does the gevent server crash with errors after a while?

There is a server written in python + gevent. Working with the database is carried out through github.com/esnme/ultramysql
Everything seems to work fine, but after 4 hours (whenever) the server crashes with errors:

Traceback (most recent call last):
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/gevent/greenlet.py", line 328, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/home/admin/server/server/connect.py", line 58, in listener
    self.dispatch(data)
  File "/usr/home/admin/server/server/connect.py", line 108, in dispatch
    self.auth(data['params'])
  File "/usr/home/admin/server/server/connect.py", line 156, in auth
    result = self.server.db.query("SELECT id, nickname FROM user WHERE id = %s", (self.userId, ))
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/gevent/socket.py", line 435, in send
    return sock.send(data, flags)
error: [Errno 32] Broken pipe
<Greenlet at 0x802ae5c30: <bound method Connect.listener of <server.connect.Connect object at 0x8028ef490>>> failed with error


Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\gevent\greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "D:\seabattle\server\server\connect.py", line 58, in listener
    self.dispatch(data)
  File "D:\seabattle\server\server\connect.py", line 108, in dispatch
    self.auth(data['params'])
  File "D:\seabattle\server\server\connect.py", line 156, in auth
    result = self.server.db.query("SELECT id, nickname FROM user WHERE id = %s", (self.userId, ))
Error: (0, 'Concurrent access in query method')
<Greenlet at 0x2c6c768L: <bound method Connect.listener of <server.connect.Connect object at 0x0000000002C81198>>> failed with Error


I sin on the driver of work with mysql, but I cannot understand the reason. It seems that the connection is torn, but why? Point to a sensible thought, if not difficult? Or advise a driver for mysql to work with gevent.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mayorovp, 2013-06-18
@mayorovp

Nevertheless, it is written: "Concurrent access in query method"
You can not call query until the previous one has been completed.
In general, it is better not to keep the connection to the database global, but to take it from the pool for the duration of the operation. Then there will be fewer problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question