-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'MySQL server has gone away' is raised when connection goes stale while adding to 'apscheduler_jobs' #228
Comments
For now I've added ping_connection in CustomJobStore which is inheriting from class MySQLAlchemyJobStore(SQLAlchemyJobStore):
def __init__(self, *args, **kwargs):
pool_pre_ping = kwargs.pop('pool_pre_ping', False)
super(MySQLAlchemyJobStore, self).__init__(*args, **kwargs)
if pool_pre_ping:
event.listen(self.engine, "engine_connect", ping_connection) Refer to http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic |
MySQL server has gone away
is raised when connection goes stale while adding to apscheduler_jobs
+1 Is there any good solution on this issue? |
@jkryanchou IMO, we should provide kwargs to |
For now you can just create your own engine with those options and pass that to the job store. |
@pranav93 I have inherit my own |
@jkryanchou +1 to that. I'm using it like that. Or as @agronholm said you can pass session to store while making sure you do |
@agronholm, do you think there is need to apply patch or library user should take care of it by customizing like |
@pranav93 Yeah. It works well for me. |
If any customizations to the engine are needed, library users should create their own Engine and pass it to the job store. That said, I could add a new argument for doing that as a shortcut. |
@agronholm , I would love to apply little patch for it :) |
I've considered two options:
|
First one is explicit so it seems cool IMO. |
It's better to expose the engine options for user to customize. |
Wouldn't both suggestions laid out above do exactly that? |
Hello! I need a bit of help here. I want to use this MySQLAlchemyJobStore instead of the default SQLAlchemyJobStore since I get this '2006' error a lot. I notice function 'ping_connection()' is defined at the first link above. But where do I get "some_engine" from.... seems that self.engine won't work.... I thought the engine gets created inside the SQLAlchemyJobStore function. I don't know where to start in the SQLAlchemy documentation - a concrete example would be best for me - what am I missing? |
When connection goes stale either because of non usage or
MySQL
restart, following error is raised,The text was updated successfully, but these errors were encountered: